1. 程式人生 > 其它 >VUE元件改變預設鉤子函式引數(給預設鉤子函式自定義引數)

VUE元件改變預設鉤子函式引數(給預設鉤子函式自定義引數)

VUE元件改變預設鉤子函式引數(給預設鉤子函式自定義引數)

<el-upload
   v-if="!checkFileBtn"
   class="eve-common-upload"
   style="margin-top:12px;"
   :accept="accept"
   :action="`${config.fileServer}/file/uploadFileTemp`"
   :on-success="(file,fileList)=>{
   return handleAvatarSuccess(file,fileList,param)
   }"
   :before-upload="beforeAvatarUpload"
   :show-file-list="false">
       <el-button :size="$size" v-if="!isDetail || FORM_ITEM_EDIT.address"
       type="primary">點選上傳</el-button>
</el-upload>

重點程式碼:

 :on-success="(file,fileList)=>{
   return handleAvatarSuccess(file,fileList,param)
   }"

JS程式碼:

// 上傳檔案成功
    handleAvatarSuccess (res, file, param) {
       console.log(param)
      this.fileLoading = false
      const fileType = file.name.split('.')[file.name.split('.').length - 1]
      const { success, msg, data } = res
      if (success) {
        this.$message.success(msg)
      } else {
        this.$message.error(msg)
      }
    }