Vue+axios实现统一接口管理的方法

2020-06-14 06:02:54易采站长站整理


axios.interceptors.response.use(response => {
const { data } = response;
if (data.status === -2) {
Vue.prototype.$Message.error(`无效的登录信息或登录已失效,请重新登录`);
delCookie("jwt");
router.push({ path: "/login" });
}
if (data.status === -1) {
Vue.prototype.$Message.error(`发生错误[${data.message}]`);
}
return response;
});

总结

以上所述是小编给大家介绍的Vue+axios实现统一接口管理的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对软件开发网网站的支持!