V
V
Vyacheslav Shevchenko2019-10-20 20:13:50
Vue.js
Vyacheslav Shevchenko, 2019-10-20 20:13:50

How to make multiple Vue with your Store?

Hello.
I want to inject vue into a page, in multiple instances. Everything is connected and working, but the Vuex store turned out to be common. How can you split a store and make it within each Vue instance?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-10-20
@WebDev2030

If you use the Vuex.Store constructor more than once, you won't be jailed for it. So nothing prevents you from creating several different stores, one for each instance of Vue.
And if their structure should be identical - make a function that will create a store and instead of

new Vue({
  store: store,
  ...

will
new Vue({
  store: createStore(),
  ...

https://jsfiddle.net/25L08xj1/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question