Answer the question
In order to leave comments, you need to log in
How to share the same vuex between different vue objects?
So let's imagine that we have two view objects attached to different DOM elements, but they really want to interact with each other like this:
product cards => vuex <= cart
does anyone have any ideas how to fasten them? Now this thing somehow works with crutches through vue-persistdate and the same vuex scheme like this
(product cards, vuex) => localstorage <= (basket , vuex
) cool and is there really no way to share it?
Answer the question
In order to leave comments, you need to log in
Just "share" an instance of the vuex store between vue applications.
import Vue from 'vue';
import Store from 'vuex';
const store = new Store({ /* настройки хранилища*/});
const app1 = new Vue({
store,
el: '#el1',
/* настройки первого приложения */
});
const app2 = new Vue({
store,
el: '#el2',
/* настройки второго приложения */
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question