上傳檔案iView元件
阿新 • • 發佈:2018-11-05
<Upload ref="upload" :before-upload="handleUpload"//上傳之前呼叫 :show-upload-list="false" :on-success="uploadSuccess2"//上傳成功呼叫 :on-error="uploadError"//上傳失敗呼叫 :format="['xlsx']"//制定上傳檔案格式 :max-size="2048"//最大 上傳檔案大小 :on-format-error="handleFormatError2"//檔案格式錯誤呼叫 :data="{noValidateType:0}" name='upload' action="/api/achievement/add_Excel_Achieve">//請求的介面 <Button type="ghost" class="upload-btn" title="上傳excel">批量匯入資料</Button> </Upload>
uploadSuccess2 (res, file) { //上傳成功
this.$Message.info(res.msg);
if(res.code == 200){
this.excel_name = res.info.originalName;
}
}
uploadError(error, file) { //上傳失敗
this.$Message.info(error);
}
handleFormatError2 (file) { this.$Message.info("檔案格式不正確,請上傳excel格式檔案"); }
uploadError(error, file) {
this.$Message.info(error);
}