You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Set default values using the global configurationVue.http.options.root='http://47.106.111.100:8088';// Set default values inside your Vue component options.newVue({http: {root: '/root',headers: {Authorization: 'Basic YXBpOnBhc3N3b3Jk'}}})
由于一直以为
vue-resource
,改不了baseUrl
以及像利用axios
来每次请求都在头部自动加上JWT_Token
(Vue 进阶教程之:Axios配置JWT/封装插件/发送表单数据),再加上就连官方都没推荐了,就一直打入冷宫,突然这次因为axios
,自己遇到一些跨域的问题,不知道到底是什么回事,就又换回了vue-resource
,现在才发现,只是自己不懂...这些原来都有改
baseUrl
:神奇的是:
而在
vue
实例中开不开http
选项都没关系...另一个注意事项就是:
也就是在写成
this.$http.post('/rest/app/register', test)
的时候是不行的,必须要在url
中写成'rest/app/register'
头部自动加上
JWT_Token
:同上所示:
Vue.http.headers.common['Authorization'] = 'Basic YXBpOnBhc3N3b3Jk';
另还有不支持json,要
application/x-www-form-urlencoded
的MIME type的转化:Vue.http.options.emulateJSON = true;
结论是:好好看文档
参考链接:
Configuration-官方文档
vue-resource headers如何动态地设置
The text was updated successfully, but these errors were encountered: