vue2.0 中上传文件
来源:互联网 发布:数控编程培训靠谱吗 编辑:程序博客网 时间:2024/06/17 04:13
用到了HTML5的新的方法fromData 结合jq中ajax进行上穿
template: 通过绑定change事件,监听选择文件的变化
<input type="file" @change="getFile">script:
data(){
return {
file: ' '
}
}
methods:{ getFile($event){ this.file = $event.target.files[0] //获取要上传的文件 },upload (){let da = New FormData()da.append("files",this.file)//da.append("name", this.name)可以逐次添加多个参数$.ajax({url: 'www.baicu.com',data: da, type: 'POST',chacke: false,processData: false, // 告诉jQuery不要去处理发送的数据
contentType: false,
// 告诉jQuery不要去设置Content-Type请求头
}).done(function(){
})
.fail(function(){
})
}}浏览器兼容性
chromefirefoxinternerExploerOperaSafari7+4+10+12+5
0 2
- vue2.0 中上传文件
- 阿里云 oss JavaScript客户端签名文件上传 vue2.0
- vue2.0中.vue文件页面跳转之.$router.push
- vue2.0中.vue文件的post请求
- Vue2.0使用总结中......
- vue2.0中使用sass
- vue2.0集成ueditor以及图片上传,视频上传总结
- 11月16日云栖精选夜读:阿里云 oss JavaScript客户端签名文件上传 vue2.0
- 11月16日云栖精选夜读:阿里云 oss JavaScript客户端签名文件上传 vue2.0
- 11月16日云栖精选夜读:阿里云 oss JavaScript客户端签名文件上传 vue2.0
- 11月16日云栖精选夜读:阿里云 oss JavaScript客户端签名文件上传 vue2.0
- 11月16日云栖精选夜读:阿里云 oss JavaScript客户端签名文件上传 vue2.0
- 11月16日云栖精选夜读:阿里云 oss JavaScript客户端签名文件上传 vue2.0
- 11月16日云栖精选夜读:阿里云 oss JavaScript客户端签名文件上传 vue2.0
- vue2.0使用weui.js的uploader组件上传图片
- vue2.0中Ajax库(axios)
- vue2.0中过滤器的使用
- vue2.0中css过渡动画总结
- 【经典智力题】1024! 末尾有多少个0?——“计算阶乘末尾0的数量”问题引出
- Android中使用动态代理模式
- Atitit需求文档模板大纲目录 attilax总结
- Spring-MVC框架下对web.xml文件及spring_mvc.xml文件内容的释义资料整理
- python的数学运算符
- vue2.0 中上传文件
- 单例模式-注意线程安全
- 快速排序
- PHP数字金额转中文大写金额
- 为什么要进行烦人的单元测试
- android中svg介绍及使用[汇总]
- Bellman-Ford的队列优化
- Atitit 团队工具链体系打造---开发方面提升效率的软件与技术体系 attilax总结.docx
- AndroidStudio插件ButterKnife的使用(库和插件)