Vue Resource root options not used?
2016-01-23 21:27
531 查看
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:
In a component :
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
Also, you need to remove the last
becomes
And with that, it will work!
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!
相关文章推荐
- 关于 [UITableView _configureCellForDisplay:forIndexPath:]断言失败问题接解决
- 测试 arduino pro mini 的 PWM
- leetcode--Unique Paths && Unique Paths ii
- Arduino入门(一)
- EasyUI parser 的使用场景
- 【leetcode】141. Linked List Cycle My Submissions Question
- poj2524——Ubiquitous Religions(并查集)
- 漢字之色 Hue in Chinese Literal Characters
- Build ffmpeg Libraries in Windows via MinGW
- leetcode之Implement Stack using Queues
- 获取UIButton的一些属性
- 调用SwingUtilities.invokeLater()将更新UI的操作放到事件派发线程中执行
- android 所有布局属性和UI控件
- perl while continue
- UIView中的坐标转换
- IOS开发UI:Quartz2D的使用
- UIImageView添加手势不响应的原因
- 通过ValueAnimator实现点击展开和关闭的效果
- break,continue,return
- 使用UEFI+GPT模式安装Windows