Element-UI upload上传文件失败 正确解析错误内容

<el-upload class="upload" :action="uploadExcelAction" :headers="headers"
		   list-type="picture" :show-file-list="false" :before-upload="beforeUpload"
		   :on-success="uploadSuccess" :on-error="uploadError" :on-progress="uploadProgress"
		   accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
  <el-button class="filter-item" icon="el-icon-upload2" type="primary" plain>
	{{ $t('table.importExcel') }}
  </el-button>
</el-upload>
// 导入Excel错误处理
uploadError(error) {
	// 关键处理,得用JSON.parse来解析error里面的内容
	// 其中message为后端返回的错误信息提示
	const result = JSON.parse(error.message);
	// 导入Excel失败提示信息
	this.$message({
		message: this.$t('tips.uploadFailed') + " " + result.message,
		type: 'error',
		showClose: true
	});
}
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 精致技术 设计师:CSDN官方博客 返回首页