有需求是循环中上传文件,选择手动上传,通过设置ref值来获取上传的节点如下,
<el-upload v-if="sign == 'add'|| item.piclist.length<1"
:ref="'upload'+index"
:multiple="false"
:limit="1"
:action="path"
:data="item"
:file-list="postData.list[index].piclist"
:headers="headers"
:on-change="handleChange"
:on-remove="handleRemove"
:on-success="handleSuccess"
:on-error="handleError"
:auto-upload="false">
<el-button size="mini" slot="trigger" type="primary" plain @click="getIndex(index)">选择文件</el-button>
</el-upload>
接下来是获取
this.$refs['upload'+this.index].submit()
好的到这就能获取了,因为没有id 所以用index ,有id用id更好一些