Я использую Vue.js 2.3.3, Vue Resource 1.3.3, Vue Router 2.5.3 и пытаюсь настроить Vue-Auth. Однако я продолжаю получать консольную ошибку с надписью auth.js?b7de:487 Error (@websanova/vue-auth): vue-resource.1.x.js : Vue.http must be set.
. Я устанавливаю Vue.http
в main.js, но vue-resource по какой-то причине его не забирает.
main.js:
import Vue from 'vue'
import Actions from 'actions'
import App from './App'
Vue.use(Actions, {
locales: ['en', 'zh', 'fr']
})
Vue.http.options.root = 'https://api.example.com'
new Vue({
render: h => h(App),
watch: {
lang: function (val) {
Vue.config.lang = val
}
}
}).$mount('#app')
действия / index.js
import VueResource from 'vue-resource'
import Router from 'actions/router'
import I18n from 'actions/i18n'
export default {
install (Vue, options) {
Vue.use(Router)
Vue.use(I18n, options.locales)
Vue.use(require('@websanova/vue-auth'), {
router: require('@websanova/vue-auth/drivers/router/vue-router.2.x'),
auth: require('@websanova/vue-auth/drivers/auth/bearer'),
http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x')
})
}
}
И если я добавлю Vue.use(VueResource)
в actions / index.js прямо под Vue.use(Router)
, я получу новую ошибку: Error (@websanova/vue-auth): vue-router.2.x.js : Vue.router must be set.
С другой стороны, если я перемещаю Vue.http.options.root = 'https://api.example.com'
прямо под операторы импорта, я получаю еще одну ошибку: Uncaught TypeError: Cannot read property 'options' of undefined
Vue.use(VueResource)
, я получаю новую ошибкуError (@websanova/vue-auth): vue-router.2.x.js : Vue.router must be set.
- person Confused One   schedule 25.05.2017