Answer the question
In order to leave comments, you need to log in
How to connect one plugin twice but with different settings?
There is a vue2-storage plugin that allows you to use the browser's localStorage.
In the settings of this plugin, you can specify the prefix that will be used for the keys.
In my Vue2 app, I need to store two kinds of data in localStorage: users and cars. These data are not related to each other and should not intersect.
Users is a list of logins as keys and their profile data as values:
evan {name: 'Evan', 'email': '[email protected]'}
piter {name: 'Piter', 'email': '[email protected]'}
eva {name: 'Eva', 'email': '[email protected]'}
...
А111АА11 {brand: 'Volkswagen', 'model': 'Polo', 'year': 2015, hp: 150}
А222АА22 {brand: 'BMW', 'model': 'X3', 'year': 2017, hp: 170}
А333АА33 {brand: 'Lada', 'model': 'Priora', 'year': 2008, hp: 98}
...
import Vue from 'vue';
import { Plugin } from 'vue2-storage';
Vue.use(Plugin, {prefix: 'users_'});
Vue.use(Plugin, {prefix: 'cars_'});
// И далее используем как то так:
this.$usersStorage.set(...);
this.$carsStorage.set(...);
...
Answer the question
In order to leave comments, you need to log in
A bit off topic, but Vuex + vuex-persistedstate worked well for solving the problem.
It is quite unexpected to see a question on the Toaster that concerns my package))
Of course the code above won't work because Vue doesn't allow two of the same plugins to be connected. Or how does it allow it?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question