I'm manually mounting a component to a dynamic element using Vue.extend like this:
import Vue from 'vue';
import MyComponent from 'MyComponent.vue';
const MyComponentConstructor = Vue.extend(MyComponent);
const MyComponent = new MyComponentConstructor({
propsData: {
foo: 123,
},
}).$mount('#mount-point');
When I manually mount a component in this way, I can't use vuex inside MyComponent.vue.:
// (inside MyComponent.vue)
this.$store.commit('setSomething', true);
I get this:
Uncaught TypeError: Cannot read property 'commit' of undefined
Of course vuex is set up and working fine in the other normal components. Is there something I can pass to the constructor to get it to work?