【发布时间】:2020-09-14 00:44:32
【问题描述】:
我们正在使用服务器端渲染,并为我们所有的 vuex 模块使用preserveState,以在从一个页面导航到下一个页面时保持状态。
但是,我们有一个特定的商店,我们不想在其中保留 一些 属性。有没有办法在 Vuex 商店中实现这一点?例如
@Module({ namespaced: true, dynamic: true, store, name, preserveState: true })
class SampleModule extends VuexModule {
propertyOne: {}; // we want to persist this
propertyTwo: {}; // we want to persist this
propertyThree: {}; // we DO NOT want to persist this
propertyThree: {}; // we DO NOT want to persist this
}
目前我们能想到的唯一方法是为那些我们不想保留的属性创建一个单独的商店。但这并不理想,因为这些属性非常相关,唯一的区别是我们是否要持久化它们。
有没有更好的办法?
【问题讨论】:
标签: javascript vue.js vuex vuex-modules