O
O
Oleg Obodin2018-10-05 13:18:22
Vue.js
Oleg Obodin, 2018-10-05 13:18:22

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

1 answer(s)
K
Klein Maximus, 2018-10-05
@saintpat

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 question

Ask a Question

731 491 924 answers to any question