您好,欢迎访问一九零五行业门户网

vue+axios表单中上传图片步骤详解

这次给大家带来vue+axios表单中上传图片步骤详解,vue+axios表单中上传图片的注意事项有哪些,下面就是实战案例,一起来看一下。
然后问题就是element 中的上传控件在没有图片的时候是不会触发提交的,但接口写的是有file的  multipart/form-data    接收模式
所有只能自己另个模仿一个表单上传
<input class="file" name="file" type="file" accept="image/png,image/gif,image/jpeg" @change="update"/>
let file = e.target.files[0];        let param = new formdata(); //创建form对象     param.append('file',file,file.name);//通过append向form对象添加数据     param.append('chunk','0');//添加form表单中其他数据         let config = {     headers:{'content-type':'multipart/form-data'}     }; //添加请求头     this.axios.post('http://upload.qiniu.com/',param,config)     .then(response=>{     console.log(response.data);     })
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
在vue里使用axios步骤详解
axios+post方法提交formdata步骤详解
npm中install出现权限问题如何处理
以上就是vue+axios表单中上传图片步骤详解的详细内容。
其它类似信息

推荐信息