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

How to use vuex store with typescript #161

Closed ujjwalguptaofficial closed 5 years ago

ujjwalguptaofficial commented 5 years ago

I was able to convert my app into custom component by using below code -

Vue.customElement('my-app', new Main().$options);

Here Main is component & Main has multiple nested child components. but dont know where to add the store.

Here is the initiate code -

// Initiate vue app
var vue_app = new Vue({
    el: '#app',
    store: store,
    render: h => h(Main)
});

please let me know. THanks.

karol-f commented 5 years ago
import Main from './Main.vue';
import store from './store';

const MainComponent = new Main().$options
MainComponent.store = store
Vue.customElement('my-app', MainComponent);

or similar usage usage should work fine. Feel free to comment if something is not working. Regards!