About how to get the data returned by the backend when uploading element el-upload.

if you want to upload an avatar, use the el-upload method of element and enter the port address to upload successfully. How do you accept the value returned by the backend?

<el-form-item label="">
   <el-upload
     class="avatar-uploader"
     action="http://192.168.1.47:9997/api/account/Upload"
     :show-file-list="false"
     :on-success="handleAvatarSuccess"
     :before-upload="beforeAvatarUpload">
     <img v-if="imageUrl" :src="imageUrl" class="avatar">
     <i v-else class="el-icon-plus avatar-uploader-icon"></i>
   </el-upload>
 </el-form-item>

the backend returned a value

clipboard.png

how do I get this value? I"d better have a code hint. I have front-end scum. Thank you, boss

.

on-success is the hook when the file is uploaded successfully. You can get the data returned from the backend in this hook.

...
:on-success="handleAvatarSuccess"
...
methods: {
    handleAvatarSuccess(response, file, fileList) {
        //response
    }
}

   handleAvatarSuccess(res, file) {
       //res
   },
Menu