Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue-auth.esm.js?3e97:691 Error (@websanova/vue-auth): drivers/router/vue-router.2.x.js: router plugin has not been set. #630

Closed
alimujtaba478 opened this issue Feb 14, 2021 · 1 comment

Comments

@alimujtaba478
Copy link

alimujtaba478 commented Feb 14, 2021

config/plugin.js

`import Vue from 'vue'

import auth from '@websanova/vue-auth/dist/v2/vue-auth.esm.js'
import driverAuthBearer from '@websanova/vue-auth/dist/drivers/auth/bearer.esm.js'
import driverHttpAxios from '@websanova/vue-auth/dist/drivers/http/axios.1.x.esm.js'
import driverRouterVueRouter from '@websanova/vue-auth/dist/drivers/router/vue-router.2.x.esm.js'
import driverOAuth2Google from '@websanova/vue-auth/dist/drivers/oauth2/google.esm.js'
import driverOAuth2Facebook from '@websanova/vue-auth/dist/drivers/oauth2/facebook.esm.js'

driverOAuth2Google.params.client_id = '547886745924-4vrbhl09fr3t771drtupacct6f788566.apps.googleusercontent.com'
driverOAuth2Facebook.params.client_id = '196729390739201'

Vue.use(auth, {
plugins: {
http: Vue.axios, // Axios
// http: Vue.http, // Vue Resource
router: Vue.router
},
drivers: {
auth: driverAuthBearer,
http: driverHttpAxios,
router: driverRouterVueRouter,
oauth2: {
google: driverOAuth2Google,
facebook: driverOAuth2Facebook
}
},
options: {
rolesKey: 'type',
notFoundRedirect: { name: 'user-account' }
}
})
`

config/index.js

`import './plugins'

export default {}
`

main.js

`import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import http from './http'
import config from './config'

import '@/icons' // icon
import '@/permission' // permission control

/**

  • If you don't want to use mock-server
  • you want to use MockJs for mock api
  • you can execute: mockXHR()
  • Currently MockJs will be used in the production environment,
  • please remove it before going online ! ! !
    */
    if (process.env.NODE_ENV === 'production') {
    const {mockXHR} = require('../mock')
    mockXHR()
    }

// set ElementUI lang to EN
Vue.use(ElementUI, { locale })

// 如果想要中文版 element-ui,按如下方式声明
// Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
el: '#app',
http: http,
store: store,
router: router,
config: config,
render: h => h(App)
})
`

@websanova
Copy link
Owner

ah ya, I mean your answer is right in the error ;-)

Router has not been installed before using vue auth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants