I've recently set up a new vue-cli webpack project with Vuex. I have initialized my Vuex store in store.js like so:
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
const store = new Vuex.Store({
state: {}
});
export default store;
Although I am importing the store from './store.js'
in my App.vue file successfully, I am encountering an issue where this.$store
is coming back as undefined. Can anyone help me figure out what I might be missing?
Below is a snippet of my App.vue for reference:
<script>
import Navigation from "@/components/Navigation";
import axios from "axios";
import store from "./store";
export default {
created() {
console.log("store from $store", this.$store);
console.log("store from store: ", store);
}
}
</script>
The second console.log(store)
seems to be working without any issues.