34 lines
766 B
JavaScript
34 lines
766 B
JavaScript
|
import Vue from 'vue'
|
|||
|
import App from './App.vue'
|
|||
|
import router from './router'
|
|||
|
import store from './store'
|
|||
|
import axios from 'axios'
|
|||
|
import "./css/common.css"
|
|||
|
|
|||
|
Vue.prototype.$http = axios
|
|||
|
|
|||
|
Vue.config.productionTip = false
|
|||
|
|
|||
|
import ElementUI from 'element-ui';
|
|||
|
import 'element-ui/lib/theme-chalk/index.css';
|
|||
|
Vue.use(ElementUI);
|
|||
|
|
|||
|
// 添加请求拦截器,在请求头中加token
|
|||
|
//使用 axios 的请求拦截器来实现在请求头中自动带上 token 的功能:
|
|||
|
axios.interceptors.request.use(
|
|||
|
config => {
|
|||
|
if (localStorage.getItem('token')) {
|
|||
|
config.headers.token = localStorage.getItem('token');
|
|||
|
}
|
|||
|
return config;
|
|||
|
},
|
|||
|
error => {
|
|||
|
return Promise.reject(error);
|
|||
|
});
|
|||
|
|
|||
|
new Vue({
|
|||
|
router,
|
|||
|
store,
|
|||
|
render: h => h(App)
|
|||
|
}).$mount('#app')
|