Vue资源根选项未使用?

vue.js Vue.js

神乐古一

2020-03-12

我在main.js文件的Vue资源中指定了根选项,但是当我执行请求时,它不使用根选项。我想念什么?

这是代码:

main.js:

Vue.http.options.root = 'http://api.domain.com/v1/'

在组件中:

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 ...
    })
}

我究竟做错了什么 ?

我正在使用Vue.js v1.0.15和Vue-Resource v0.6.1

谢谢您的帮助。

第1141篇《Vue资源根选项未使用?》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android