夜深了。我直接贴代码吧,好困- -
<el-upload
v-for="(item, key, index) in tags"
:key="item+key+index"
class="avatar-uploader"
action="http://upload-z2.qiniu.com/"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:data="qiniuToken"
>
<img v-if="imageUrl" :src="imageUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
js
data() {
return {
imageUrl: '',
qiniuToken: {
token: ''
}
}
},
methods: {
//想知道触发了哪个el-upload,想获取下标
handleAvatarSuccess(res, file, fileList) {
console.log(res,'res', fileList, 'fileList',file, 'file')
// console.log(index,'index')
this.imageUrl = URL.createObjectURL(file.raw);
}
}
想知道触发了哪个el-upload,想获取index,大概的需求就是这样子。
el-upload文档