Vue Resource root options not used?
I specify a root options in my Vue-Resource in my main.js file, but when I do the request, it does not use the root options. What am I missing ?
Here's the code :
main.js:
Vue.http.options.root = 'http://api.domain.com/v1/'
In a component :
ready: function () {
console.log(this.$http.options.root) // Correctly show 'http://api.domain.com/v1/' this.$http.get('/members/', null, { // FAILS because it tries to load /members/ in the current domain
headers: {'auth-token': 'abcde'}
}).then(function (xhr) {
// process ...
})
}
What am I doing wrong ?
I'm using Vue.js v1.0.15 and Vue-Resource v0.6.1
Thank you for your help.
answer:
Ohoh this is tricky !
In order for root to be taken into consideration, you need to remove the initial /
from the url :
this.$http.get('/members/') becomes this.$http.get('members/')
Also, you need to remove the last /
in the root :
Vue.http.options.root = 'http://api.domain.com/v1/'
becomes
Vue.http.options.root = 'http://api.domain.com/v1'
And with that, it will work!
Vue Resource root options not used?的更多相关文章
- vue resource 携带cookie请求 vue cookie 跨域
vue resource 携带cookie请求 vue cookie 跨域 1.依赖VueResource 确保已安装vue-resource到项目中,找到当前项目,命令行输入: npm instal ...
- vue之$root,$parent
$root vue状态管理使用vuex,如果项目不大,逻辑不多,name我们没必要用vuex给项目增加难度,只需要用$root设置vue实例的data就行了,如下 main.js new Vue({ ...
- vue 中 this.$options.data() 重置
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- vue -resource 文件提交提示process,或者拦截处理
this.$http.post('url',fd||data,{emulateJSON:true}).then(fn(res){},fn(res){}) process成功案例 _self.$http ...
- vue resource 携带cookie请求 vue cookie 跨域(六)
1.依赖VueResource 确保已安装vue-resource到项目中,找到当前项目,命令行输入: npm install vue-resource --save 在主方法添加 过滤 Vue.h ...
- vue resource patch方法的传递数据 form data 为 [object Object]
今天在测试 iblog 登录时,传送过去的数据总是 [object Object],以至于后台识别不出来. vue 使用了 vueResource 组件,登录方法为 patch. 经过探索,终于在官网 ...
- [VUE ERROR] Invalid options in vue.config.js: "publicPath" is not allowed
项目在build的时候报的这个错误: 具体原因是因为版本支持的问题,publicPath 属性到 vue-cli 3.2.0 之后才支持,所以将 publicPaht 改成 baseUrl 即可,或者 ...
- vue前后台数据交互vue-resource文档
地址:https://segmentfault.com/a/1190000007087934 Vue可以构建一个完全不依赖后端服务的应用,同时也可以与服务端进行数据交互来同步界面的动态更新. Vue通 ...
- 用vue构建多页面应用
最近一直在研究使用vue做出来一些东西,但都是SPA的单页面应用,但实际工作中,单页面并不一定符合业务需求,所以这篇我就来说说怎么开发多页面的Vue应用,以及在这个过程会遇到的问题. 准备工作 在本地 ...
随机推荐
- Xamarin Essentials教程设备信息DeviceInfo
Xamarin Essentials教程设备信息DeviceInfo 设备信息包括设备类型.设备种类和操作系统.应用程序通过获取设备信息,可以判断当前程序是否适合在该设备上运行.例如,优酷提供TV ...
- 南阳325----zb的生日
//重量太大,用01背包容易超时 //数据只有20组.可以用dfs搜索最优解 #include<stdio.h> ]; int maxs,n,s; void dfs(int,int); i ...
- QtQuick自定义主题以及控件样式指引
自定义控件样式 请在Qt帮助索引中输入Customizing a Control进行查看 不过实际用下来感觉除非你想自己实现一套效果复杂的UI或是创造一个全新控件,比如:给UI添加模糊.虚化等Shad ...
- BZOJ.3811.玛里苟斯(线性基)
BZOJ UOJ 感觉网上大部分题解对我这种数学基础差的人来说十分不友好...(虽然理解后也觉得没有那么难) 结合两篇写的比较好的详细写一写.如果有错要指出啊QAQ https://blog.csdn ...
- SFTPUtils工具类及使用
配置maven <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</arti ...
- 以加密方式访问tomcat服务器
以加密方式(https)访问tomcat服务器,就要求对相应的端口配置加密连接器connector. 配置加密连接器的方法如下: 1.生成数字证书 利用jdk里的keytool生成证书,keytool ...
- 如何查看linux版本信息
查看系统信息 [root@root]# hostnamectl Static hostname: root Icon name: computer-desktop Chassis: desktop M ...
- C++程序设计方法5:接口设计实例
//例子:旋转方阵填充,要求矩阵大小任意,尺寸在运行时输入 设计思路:从上到下 int main() { cout << "Please input N:"; int ...
- PAT基础6-1
6-1 简单输出整数 (10 分) 本题要求实现一个函数,对给定的正整数N,打印从1到N的全部正整数. 函数接口定义: void PrintN ( int N ); 其中N是用户传入的参数.该函数必须 ...
- 超级牛皮的oracle的分析函数over(Partition by...) 及开窗函数 (转)
http://zonghl8006.blog.163.com/blog/static/4528311520083995931317/ over(Partition by...) 一个超级牛皮的ORAC ...