vue+webpack的基础上应该怎么给请求设置一个header。 代码如下,在main.js里面设置了header,后端获取不到。 Vue.http.interceptors.push(function (request, next) { if(request.url !== 'http://211.149.193.19:8100/token'){ request.headers.Authorization = 'Bearer ' + sessionStorage.getItem('accessToken') console.log(request.headers) } this.showLoading = true // console.log(this) // 如果用箭头函数 此处则打印出undefined next(function (response) { response.headers.Authorization = 'Bearer ' + sessionStorage.getItem('accessToken') if (!response.ok) { this.errorCode = response.status this.showDialog = true } this.showLoading = false return response }); });I‘m webapp-cnodejs-vue
回复 (9)
测试一下
用fetch 吧 From Noder
asdasd
saasf
test二次开发的 webapp-cnodejs-vue
@TerrenceFong test二次开发的 webapp-cnodejs-vue
@TerrenceFong test二次开发的 webapp-cnodejs-vue
@TerrenceFong @TerrenceFF test二次开发的 webapp-cnodejs-vue
asdfasdf