request.js全局拦截响应结果
else if (res.code === 40012) { // 权限不足
Message({
message: res.msg || 'Error',
type: 'error',
duration: 3 * 1000
})
return Promise.reject(new Error(res.msg || 'Error'))
}
api请求后加catch捕获异常
sysUserApi.disableById(row.userId).then(res => {
this.$message.success(res.msg)
this.getByPage()
}).catch((e) => {
console.log(e)
})
可在catch中关闭loading