我在尝试把vue-auth安装到我的laravel-vue应用程序中。但我得到的控制台错误
错误(@websanova/vue-auth):驱动程序/ http /axos.js:尚未设置http插件。未定义的TypeError: this.plugins.http未定义
这是我的app.js文件内容
import 'core-js/stable'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import VueAxios from 'vue-axios'
import CoreuiVue from '@coreui/vue'
import { iconsSet as icons } from './assets/icons/icons.js'
import store from './store'
import VueAuth from '@websanova/vue-auth/dist/v2/vue-auth.esm.js';
import auth from './auth';
Vue.prototype.$apiAdress = 'http://127.0.0.1:8000'
Vue.config.performance = true
Vue.use(CoreuiVue)
Vue.use(VueAuth,auth)
new Vue({
el: '#app',
router,
store,
icons,
template: '<App/>',
components: {
App
},
})和auth.js含量
import Vue from 'vue'
import bearer from '@websanova/vue-auth/dist/drivers/auth/bearer.esm'
import axios from '@websanova/vue-auth/dist/drivers/http/axios.1.x.esm';
import router from '@websanova/vue-auth/dist/drivers/router/vue-router.2.x.esm';
// Auth base configuration some of this options
// can be override in method calls
const config = {
plugins: {
http: Vue.axios, // Axios
router: Vue.router,
},
drivers: {
auth: bearer,
http: axios,
router: router,
tokenDefaultName: 'token',
tokenStore: ['localStorage'],
rolesVar: 'role',
// registerData: {url: 'auth/register', method: 'POST', redirect: '/login'},
loginData: {url: 'login', method: 'POST', redirect: '/dashboard', fetchUser: true},
logoutData: {url: 'logout', method: 'POST', redirect: '/login', makeRequest: true},
fetchData: {url: 'user', method: 'GET', enabled: true},
refreshData: {url: 'refresh', method: 'GET', enabled: true, interval:30 },
authRedirect: { path: '/' },
parseUserData(response){
let data = response.data;
data.refresh = response.refresh_token;
localStorage.setItem("user", JSON.stringify(data));
return data;
}
},
options: {
rolesKey: 'type',
notFoundRedirect: {name: 'user-account'},
}
}
export default config 我遵循本教程https://websanova.com/docs/vue-auth/guides/startup设置。请帮我找出我做错了什么。LaravelFramework8.6.0和vue":"^2.5.17"。
提前谢谢。
发布于 2021-09-24 09:59:14
我可以找到一个solution.And,可以用https://websanova.com/docs/vue-auth/guides/startup教程指南来解决这个问题。
安装websanova/vue-auth插件后,必须在安装插件之前设置一些依赖项。
路由器
必须设置Vue.router,然后与安装有插件的路由器驱动程序相对应。
HTTP
必须设置一个http插件,然后该插件对应于与插件一起安装的http驱动程序。
以及config.
Git:https://github.com/websanova/vue-auth/tree/master/demos/2.x/src I在git main.js文件中安装应用程序。
而且起作用了。
https://stackoverflow.com/questions/69309797
复制相似问题