dumb question.. using $gates in store? - $gates is undefined
baradhili opened this issue · comments
I've probably just had my brain go to sleep but when trying to use
this.$gates.setRoles()
in the store (I've fetched user data inc roles and perms and want to load them) I also tried $gates.setRoles()
with the same result
I get Uncaught (in promise) TypeError: this.$gates is undefined
I'm new to Vue in general so I've probably done something wrong :)
I do have it in my main.js
import { createApp } from 'vue'
import App from './App.vue'
import { store } from './store/index.js'
import { router } from './routes/index.js'
import VueGates from 'vue-gates';
const app = createApp(App)
app.use(store)
app.use(router)
app.use(VueGates)
app.mount('#app')
outside of store I can see $gates, just inside I can't.. this is under vue v3.0.5
I solved in this way for other files, but I think it should work
import Vue from "vue";
import VueGates from 'vue-gates'
Vue.use(VueGates, {
persistent: true
});
const vueGates = Vue.prototype.$gates;
Of maybe test install Vue.use()
before your store.