How to delete the current picture by using the el-upload component of element-UI? click to determine the background return value and then delete the image.

  1. when uploading an image using element-UI, click the delete button for the uploaded image filelist, and the pop-up confirmation button starts to request the backend, and then delete the image after the correct result is returned by the backend.
  2. Code:
  Link description  

Mar.20,2021
In

upload, there is a before-remove-the hook before deleting the file. The parameter is the uploaded file and the file list. If false or Promise is returned and reject, is returned, the deletion will be stopped. It was written in the document.
Pop-up confirmation in before-remove


my solution is:

methods:{
  reqDeletePic (file,fileList) {
      this.$confirm(', ?', '', {
                    confirmButtonText: '',
                    cancelButtonText: '',
                    type: 'warning'
                }).then(() => {
                    this.asyncReq(file,fileList) // 
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: ''
                    });
                });
       return false; // ,false
      },
    asyncReq (file,fileList) {
        // 
        // fileListfile
    }
Menu