boenfu / vuex-along

:memo: auto save and restore state for vuex
https://boenfu.github.io/vuex-along/
MIT License
259 stars 36 forks source link

刷新时报错: TypeError: Cannot read property 'length' of undefined #30

Closed cnyy99 closed 5 years ago

cnyy99 commented 5 years ago
TypeError: Cannot read property 'length' of undefined
    at VuexAlong.saveData (main.js?5a86:83)
    at eval (main.js?5a86:121)
    at eval (vuex.esm.js?edaa:392)
    at Array.forEach (<anonymous>)
    at Store.commit (vuex.esm.js?edaa:392)
    at Store.boundCommit [as commit] (vuex.esm.js?edaa:335)
    at eval (Login.vue?73b5:57)
cnyy99 commented 5 years ago
const store = new Vuex.Store({
    state: {
        isLogin: false,
        account: null,
        member: null,
        savings: null,
        balances: null,
        finances: null,
        borrowings: null,
    },
    mutations: {
        ...
    },
    actions: {},
    plugins: [
        logger,
        createVuexAlong({
            session: true,
        })],
});
boenfu commented 5 years ago

你好 😄

  /**
   * 可选,sessionStorage 的配置, 默认未开启。
   */
  session?: WatchOptions;
  /**
   * 可选,是否仅使用 sessionStorage,默认 false。
   */
  justSession?: boolean;
boenfu commented 5 years ago

session 的配置是一个对象

interface WatchOptions {
  /**
   * 需要监听的属性名或模块名的字符串列表
   */
  list: string[];
  /**
   * 可选,false 为保存 list, true 为过滤 list,默认 false。
   */
  isFilter?: boolean;
}