In ElementUI, the el-upload upload image component uploads successfully function to pass custom parameters

1. When adding test questions, you need to upload a picture for each test question option. You need to correspond to the location of each picture and the option. You
need to pass a custom parameter to the function to indicate the location of the picture, but it is found that the upload is successful Functions cannot pass custom parameters
Official documents:

Insert picture description here
2. I learned a way by checking the information: on-success="(res,file)=>{handleAvatarSuccess(item,res,file)}" so that you can pass custom parameters

 <el-upload
            class="avatar-uploader uploadImg"
            :show-file-list="false"
            action="https://jsonplaceholder.typicode.com/posts/"
            :headers="{
    
    'Authorization':'Bearer '+ token}"
           :on-success="(res,file)=>{
    
    handleAvatarSuccess(item,res,file)}"
          > 
            <img v-if="item.img" :src="item.img" class="avatar">
            <i v-else class=" avatar-uploader-icon"> 上传图片</i>
              <i class="el-icon-circle-close"></i>
          </el-upload>

Guess you like

Origin blog.csdn.net/qq_45894929/article/details/109492050