vuex:
const store = new Vuex.Store({
state,
getters,
actions,
mutations,
plugins: [createLogger()]
});
export default store;
axios:二次封装
import axios from 'axios';
import ip, {token} from './ip';
import store from '@/store';
console.log(store); // 访问到的store是undefined
import Store from '@/utils/store';
// 禁止带cookie请求
axios.defaults.withCredentials = false;
// 添加请求拦截器
axios
.interceptors
.request
.use(config => {
config.headers.common['Authorization'] = Store.get('token');
return config;
}, error => {
return Promise.reject(error);
});
export default axios;
开心每一天1111
炎炎设计
qq_花开花谢_0
温温酱
相关分类