vue 上传-传参的问题 el-upload before-upload增加传参

HTML
                <el-upload
                    action="#"
                    class="avatar-uploader"
                    :data="{ type: 'cover', id: item.id }"
                    :show-file-list="false"
                    :before-upload="file => beforeUploadFun(file, item.id)"
                    :http-request="uploadSrc"
                  >
                    <i class="el-icon-edit" title="编辑"></i>
                  </el-upload>

 

js

async uploadSrc(e) {
      const url = await this.cos(e); 
      if (e.data.type == "height") {
        params.heightUrl = url;
      } else {
        params.imgUrl = url;
      }
},

  beforeUploadFun(file, id) {
    console.log(file);
    console.log(id);
  },

 

 

posted @ 2022-06-23 17:31  小小——开心  阅读(830)  评论(0编辑  收藏  举报