我们在上传多个文件时, 循环绘制模板, el-upload 拿不到当前操作的节点 , 可以在其外层增加一个div 加上点击事件,记下当前操作节点, 代码如下
<el-form-item
:label="val.label+':'"
v-for="(val, key, index) of orther_license_info"
:key="key + '_'+index"
:prop="key">
<el-col :span="8">
<el-input
type="text"
readonly
v-model="conf[key]"
></el-input>
</el-col>
<el-col offset="1" :span="7">
<div @click="fileDivClick(key)">
<el-upload
:on-change="fileChange"
:show-file-list="false"
:auto-upload="false"
:accept="key!=='otherQualification'?'image/jpeg,image/png':'image/jpeg,.zip'"
>
<el-button slot="trigger" type="primary" style="width: 83px" >{{val.sltFlg?"已选择":"选择文件"}}</el-button>
<el-button class="margin-left-10" type="primary" @click="uploadFile(key)">上传文件</el-button>
</el-upload>
</div>
</el-col>
</el-form-item>
事件
fileDivClick(curKey){
this.curKey = curKey
},
fileChange(file, fileList) {
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。