I am trying to work with global variables with Vuex but also I do keep getting undefined
error even I initialize Vuex
using Vue.use();
.
TypeError: Cannot read property 'isAuth' of undefined
store.js:
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
export default new Vuex.Store({
isAuth: true,
});
main.js:
import store from './store/store';
....
new Vue({
el: '#app',
store,
router,
render: h => h(App),
.......
I call isAuth
to see its value like this: this.$store.isAuth;
and this causes the undefined
error.
I did initialize Vuex
in store.js
, but am still having the undefined
error. Is there something I am missing?