Vue+axios 拦截,超时登录问题

axios.interceptors.request.use(config => config, error => Promise.reject(error));

axios.interceptors.response.use((response) => {
  const status = response.data.statusCode;
  if (status === 'AAM-ER-301' || status === 'AAM-ER-302' || status === 'AAM-ER-303') {
    alert('已超时,请重新登录');
    if (sessionStorage.getItem('isNaigation') === 'yes') {
      window.parent.location.href = '/';
    } else {
      window.location.href = '/';
    }
  } else return response;
}, error => Promise.reject(error));

参考: https://blog.csdn.net/H1069495874/article/details/80057107  

posted @ 2019-07-01 16:45  拈花醉  阅读(1071)  评论(0)    收藏  举报