element-ui Upload上传组件 动态配置action
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
<el-upload
class="upload-file"
ref="upload"
:limit="currentTableData.length"
:headers="upload.headers"
:action="upload.newurl"
:on-exceed="handleExceed"
:before-remove="beforeRemove"
:before-upload="handleFileBefore"
:auto-upload="false"
multiple
>
export default {
data() {
return {
// 上传参数
upload: {
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
newurl:'',
url: process.env.VUE_APP_BASE_API + "/nfm/nfmfile/upload/",
relationid:null,
},
}
},
methods: {
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 ${this.currentTableData.length} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${ file.name }?`);
},
handleFileBefore(file){
return new Promise((resolve, reject) => {
// 拼接上传url
// 此处动态配置action URL
this.upload.newurl = this.upload.url + this.upload.relationid;
// dom上传地址更新完成后,触发上传
this.$nextTick(() => resolve());
});
},
}
原文地址:https://blog.csdn.net/github_39121448/article/details/121647945
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:3 个月前 )
c345bb45
7 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献1条内容
所有评论(0)