【问题标题】:Vuex-persist throws Uncaught TypeError: s is not a functionVuex-persist 抛出 Uncaught TypeError: s is not a function
【发布时间】:2021-01-07 11:00:43
【问题描述】:

这是我的代码: 我不知道到底是什么问题,也许有人知道如何解决它!

const vuexLocal = new window.VuexPersistence.VuexPersistence({
    storage: window.localStorage,
});
const visits = {
    state: {
        visit: []
    },
    mutations: {
        addVisit(state, data) {
            state.visit.push({
                    "id": data["id"],
                    "full_name": data["full_name"],
                    "entranceweight": data["entranceweight"],
                    "dispatched": data["dispatched"],
                    "vehicletype": data["vehicletype"],
                });
        },
    },
};
const visitStore = new Vuex.Store({

    modules: {
        visit: visits,
    },

    plugins: [ vuexLocal.plugin, ]
});

它说 Uncaught TypeError: s is not a function | vuex-persist.js 1:657

【问题讨论】:

  • 你能在 CodePen 中重现这个问题吗?

标签: javascript html vue.js vuex


【解决方案1】:

我最近也遇到了类似的问题。在我看来,最新版本不稳定并导致此问题。如果您直接在浏览器中更新,则需要导入最新的稳定版本。

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuex-persist@2.2.0"></script>

我也已将问题提交给 repo,但这是目前解决问题的一种方法。

https://github.com/championswimmer/vuex-persist/issues/201

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-01
    • 2014-08-15
    • 2021-12-16
    • 2018-04-20
    • 2017-04-13
    • 2015-01-14
    相关资源
    最近更新 更多