Vuex持久化vuex-persistedstate

import createPersistedState from 'vuex-persistedstate';

const store = new Vuex.Store({
    plugins: [
        createPersistedState({
            storage: window.sessionStorage, //state中的数据存储到sessionStorage
            reducer(val) {
                return {
                    user: val.user //只储存state中的user
                };
            }
        })
    ]
});

你可能感兴趣的:(vuex,vue)