let whitelist = [‘/login‘] // 拦截器白名单,登录时不添加 token axios.interceptors.request.use( config => { // 拦截白名单以及添加token if (whitelist.includes(config.url)) { return config } else { let token = localStorage.token config.headers.token = token return config } }, err => { return err } )