我的组件中有一些数据,这些数据设置为存储状态,如下所示:
data() {
return {
days: [],
selectedDate: this.selectedDateComputed,
dayJs: this.$store.state.dayJS,
};
},
但是当商店状态更新时 它不会更新组件中的dayJs状态。
我试图使它成为一个计算属性,并且具有selectedDate数据,如下所示:
selectedDateComputed() {
return this.$store.state.dayJS;
},
但selectedDate也不更新。
答案 0 :(得分:0)
如果要检测商店状态的更改,则需要使用Vuex提供的mapState
帮助程序功能。看看the docs。
import { mapState } from "vuex";
export default {
// ...
computed: {
...mapState(["dayJS"])
}
}