通过Upload 的action方法 返回不了结果,可以通过on-success方法中获取返回结果
<Upload accept=".xls, .xlsx" :action="uploadUrl" :on-success="onSuccess" :on-error="handleError" :before-upload="beforeUpload" style="float:right">
<Button type="primary" icon="ios-cloud-upload-outline" >导入</Button>
</Upload>
--------------------------------------------------------------------------------------------------------------
computed: {
uploadUrl() {
return baseUrl + "/ImportExcel/";
}
//file为ImportExcel方法返回的结果
onSuccess(file){
if(file.code=="1")
{
this.$Message.error("导入失败:" + file.msg);
return;
}
},
本文介绍如何使用Vue中的Upload组件实现文件上传功能,并通过onSuccess回调处理上传结果,展示错误消息。文章详细解释了如何设置uploadUrl,以及如何在上传成功后检查返回的状态码和消息。

1万+

被折叠的 条评论
为什么被折叠?



