Persistedstate LocalStorage not work.
[issue link]Can not figure out and find right solution. Everything not work.
After authentication, i need to save data not only to Store and to localStorage, but also synchronize everything. That after page reload, user will be authed.
nuxt.conf
plugins: [
{ src: '~/plugins/localStorage', ssr: false }
],
localStorage.js
import createPersistedState from 'vuex-persistedstate'
export default ({store}) => {
createPersistedState({
storage: {
getItem: key => localStorage.getItem(key),
setItem: (key, value) => localStorage.setItem(key, value),
removeItem: key => localStorage.removeItem(key)
}
})
}
example.vue component
import MyPlugin from '~/plugins/localStorage'
export default {
created() {
console.log(MyPlugin);
console.log(MyPlugin.local);
console.log(MyPlugin.setting);
// console.log(MyPlugin.storage.getItem('token'));
// console.log(MyPlugin.getItem('token'));
console.log(this.$store.local);
console.log(this.$store.setting);
},
Nothing works
`[HMR] connected
form.vue?385a:89 ƒ (_ref) {
var store = _ref.store;
Object(__WEBPACK_IMPORTED_MODULE_0_vuex_persistedstate__["a" /* default */])({
storage: {
getItem: function getItem(key) {
…
form.vue?385a:90 undefined
form.vue?385a:91 undefined
form.vue?385a:95 undefined
form.vue?385a:96 undefined`