vue+el-upload实现单文件多文件上传
1、单文件上传
<el-form-item :label="$t('Version.Attachment')">
<el-upload
class="upload-demo"
action="#"
:headers="myHeaders"
:before-remove="beforeRemove"
:on-change="nowFile"
:multiple="false"
:auto-upload="false"
>
<el-button size="small" type="primary" plain>选择附件</el-button>
<div slot="tip" v-if="showTip">只能上传apk文件</div>
</el-upload>
</el-form-item>
<div class="text-center">
<el-button size="medium" type="primary" @click="checkSave()">{
{
$t("buttons.save")
}}</el-button>
</div>
var token = window.localStorage.getItem("access_token");
export default {
data() {
return {
versionDetail: {
},
showTip: true,
myHeaders: {
Authorization: "bearer " + token },
files:{
},
keyId:''
};
},
created() {
this.getData(1);
},
methods: {
beforeRemove(file, fileList) {
this.$confirm(`确定移除 ${
file.name}?`,"提示",{
confirmButtonText: "确定",
cancelButtonText: "取消",
}).then(()=>{
this.files = {
}
this.sh