vue项目中,用axios获取当前页面header信息
组件中,引入axios,get请求当前页面,在拦截器中获取config
import axios from ‘axios’
created(){
// 添加请求拦截器
axios.interceptors.request.use(function (config) {
// 这里打印的config就可以获取到header信息
console.log(config)
return config;
}, function (error) {
// 对请求错误做些什么
return Promise.reject(error);
});
axios({
url: 'http://localhost:8081/user', //当前页面地址
method: 'get',
})
}
本文来自博客园,作者:zwbsoft,转载请注明原文链接:https://www.cnblogs.com/zwbsoft/p/16269344.html
电话微信:13514280351

浙公网安备 33010602011771号