先看图

讯享网
1.首先是输入框的状态 type值改成file 这里的accept是你上传的文件格式他直接就帮你过滤掉不是这个后缀的文件

<input ref="excel-upload-input" class="excel-upload-input" id="chooseFile" type="file" accept=".apk, .exe" @change="uploadChangeFun($event)">
讯享网
2.然后就是当前绑定的chenge事件

这里注意这里的colophonimport是接口 formdata是需要给接口传的参数

讯享网 uploadChangeFun(e) { this.loading=true const files = e.target.files; this.file = files[0] var formData=new FormData() formData.append('file',this.file) colophonimport(formData).then((res) => { if(res.code==){ this.loading=false this.response=res.code this.$message({ message: res.message, type: 'success' }); }else{ this.loading=false } }); },

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/30612.html