Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

how can i use dynamic key #418

Closed
bestRenekton opened this issue Jun 30, 2021 · 2 comments
Closed

how can i use dynamic key #418

bestRenekton opened this issue Jun 30, 2021 · 2 comments

Comments

@bestRenekton
Copy link

  • vuex-persistedstate version:4.0.0-beta.3
  • node version:15.1.0
  • npm (or yarn) version:1.22.10

Relevant code or config

createPersistedState({
key:'user1',
...
})

Problem description:
when user1 login, we save his data as 'user1' by localstorage
then he logout and user2 login
so how can we save his data as 'user2' by localstorage ? we want their both data in localstorage,because user1 maybe login next time.

Suggested solution:
in vuex module , this can do work, but It's too cumbersome,because we have many module

const state: userModuleState = {
  userInfo: {
    user1:{...}
     user2:{...}
   }
};

so can vuex-persistedstate set dynamic key ?

@robinvdvleuten
Copy link
Owner

Please ask questions on either StackOverflow or any Vuejs related forum. The issue tracker is for issues only.

@paraself
Copy link

The issues is that the documentation does not demonstrate clearly how to change the prefix dynamically after the vuex store is instantiated and createPersistedState is called.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants