karol-f / vue-custom-element

Vue Custom Element - Web Components' Custom Elements for Vue.js
https://karol-f.github.io/vue-custom-element/
MIT License
1.97k stars 187 forks source link

Global Vuex Store #177

Closed lmlong-huynh closed 5 years ago

lmlong-huynh commented 5 years ago

Hey, so I have two diffent custom-element hosted on a main app. Is it possible to let my two custom-elements using the same store as the main app?

karol-f commented 5 years ago

Sure:

import Component1 from 'Component1.vue';
import Component2 from 'Component1.vue';

const store = new Vuex(...);
Component1.store = store;
Component2.store = store;

Vue.customElement('my-component1', Component1);
Vue.customElement('my-component2', Component2);

Regards.