<el-upload
:auto-upload="false"
:on-success="success_file"
:on-change="changeFile"
:on-error="onerror"
:headers="headers"
:with-credentials="true"
:show-file-list="false"
:limit="1"
ref="upload"
:action="`${url}/baseParam/courseTypeParam/importCourseTypes`"
accept='.xls,.xlsx'
>
<el-tooltip class="item" effect="dark" content="批量导入课程分类" placement="top">
<div class="img"></div>
</el-tooltip>
</el-upload>
computed: {
headers() {
return {
'Authorization': this.tokenId ,
}
},
}
//还有一种需求是 不立刻上传需要二次确认之后 :auto-upload="false"主要是这个属性
changeFile(file){
if(file.status=='ready'){
this.$confirm(`上传将覆盖所以分类?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// this.headers = {
// Authorization: this.tokenId
// }
console.log(this.$refs.upload)
this.$refs.upload.submit();
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
this.$refs.upload.clearFiles();
});
}
},
vue el-upload 上传设置请求头 二次确认
最新推荐文章于 2024-12-10 16:26:34 发布