Vuex/Vue: 如何深度观察映射状态?

Vuex/Vue: how to deep watch a mapped state?

我正在将映射状态导入组件:

...mapState('data/story', {
  fullStories: 'stories',
}),

这将给 fullStories 状态 stories 的值,它是一个对象。

例如:

this.fullStories = { storyName: "Blah Blah", isActive: false };

我正在尝试在 isActive 上使用 watch,在 fullStories 上使用 属性。我该怎么做呢?

你可以试试 :

...mapState('data/story', {
  isActive: (state) => state.fullStories.isActive
})

或者您可以创建 vuex getter 以从存储对象中获取 isActive