在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue 獲取index

vue 獲取index

夜深了。我直接貼代碼吧,好困- -

  <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: {
    //想知道觸發(fā)了哪個el-upload,想獲取下標
    handleAvatarSuccess(res, file, fileList) {
      console.log(res,'res', fileList, 'fileList',file, 'file')
      // console.log(index,'index')
      this.imageUrl = URL.createObjectURL(file.raw);
    }
}

想知道觸發(fā)了哪個el-upload,想獲取index,大概的需求就是這樣子。
el-upload文檔

回答
編輯回答
陌離殤

兩種方法都可以。謝謝大神!@hxlyd @ms_liuy

2018年7月20日 02:11
編輯回答
吃藕丑
:on-success="handleAvatarSuccess"    //默認res, file, fileList 三個參數(shù)

* 想要把 index 在傳進去
:on-success="(res, file, fileList ) => handleAvatarSuccess(res, file, fileList , index)"

2018年1月2日 03:01
編輯回答
別逞強
:on-success="handleAvatarSuccess.bind(null, index)
handleAvatarSuccess(index, res, file, fileList) 
2017年12月19日 20:12