vue-resource怎么设置头部的header
详见 帮助文档https://github.com/pagekit/vu...
推荐使用https://github.com/mzabriskie...
用拦截器设置request
Vue.http.interceptors.push((request, next) => { request.headers['xxx'] = xxx; next(response => { ... }); });
Interceptors
Interceptors can be defined globally and are used for pre- and postprocessing of a request. If a request is sent using this.$http or this.$resource the current Vue instance is available as this in a interceptor callback.
Request processing
Vue.http.interceptors.push(function(request, next) { // modify method request.method = 'POST'; // modify headers request.headers.set('X-CSRF-TOKEN', 'TOKEN'); request.headers.set('Authorization', 'Bearer TOKEN'); // continue to next interceptor next(); });
摘自文档 https://github.com/pagekit/vu...像一楼说的,vue.resource( 2.0后不再更新)推荐使用 axios https://github.com/mzabriskie...
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(3)
详见 帮助文档
https://github.com/pagekit/vu...
推荐使用
https://github.com/mzabriskie...
用拦截器设置request
Interceptors
Interceptors can be defined globally and are used for pre- and postprocessing of a request. If a request is sent using this.$http or this.$resource the current Vue instance is available as this in a interceptor callback.
Request processing
摘自文档 https://github.com/pagekit/vu...
像一楼说的,vue.resource( 2.0后不再更新)
推荐使用 axios https://github.com/mzabriskie...