【发布时间】:2026-02-06 19:00:02
【问题描述】:
我正在尝试查看是否可以使用观察者方法来查找计算属性中的更改,而不是在此处查看各个商店属性。这会起作用还是只能用于数据属性和道具?
computed: {
optionsTrue() {
return this.$store.getters.getOption1IsTrue && this.$store.getters.getOption2IsTrue
}
},
watch: {
optionsTrue(newVal) {
// would this work to check when the value of the computed property has changed or can watcher only watch data properties?
}
}
【问题讨论】:
-
是的,它会起作用的。试试看吧。
-
是的,观察者可以用来观察计算属性。