情景
响应数据结构
{"code":401,"success":false,"data":null,"msg":"请求未授权"}
在
layui.all.js中修改
- 全局搜索
数据接口请求异常 - 具体参考的代码部分
//增加表格网络请求的401提示
if(Object.prototype.hasOwnProperty.call(e,"status") && e['status']=='401'){ //状态码为401统一拦截
if(Object.prototype.hasOwnProperty.call(e,"responseJSON")){
var responseJSON=e['responseJSON']
if(Object.prototype.hasOwnProperty.call(responseJSON,'code') && responseJSON['code']=='401'){
layui.layer.msg(responseJSON['msg'] || "无操作权限")
}
}
}
- 参考截图的位置