页面代码
<!--导入--><!--:data绑定传到后台的参数--><el-uploadstyle="display: inline-flex":show-file-list="false":before-upload="beforeUpload":on-success="onSuccess":on-error="onError":disbaled="iDisable":data={id:this.id}action="/dormitry/info/excel/upload"><!--url--><el-button :icon="iIcon" :disabled="iDisable">{{iText}}</el-button></el-upload>
js代码
return {iDisable: false,iText: '导入数据',iIcon: 'el-icon-upload2',}//导入beforeUpload() {this.iIcon= 'el-icon-loading';this.iText= '上传中...';this.iDisable= true;},onSuccess(resp, file, fileList) {this.iIcon= 'el-icon-upload2';this.iText= '导入数据';this.iDisable= false;if(resp.status == 500){this.$message.error({message:resp.msg});}else{this.$message.success({message:resp.msg});this.initDate();//初始化页面刷新数据}},onError() {this.iIcon= 'el-icon-upload2';this.iText= '导入数据';this.iDisable= false;this.$message.error('导入失败');},
如果觉得《Upload_上传_并传递额外参数》对你有帮助,请点赞、收藏,并留下你的观点哦!