使用 Vuetifyjs v1.5,我能够使用 vue 观察程序动态更改主题。 这不再适用于 Vuetifyjs 2.0
Vue版本:2.6.10 验证:2.0 Vuex:3.1.1
export default {
data() {
return {
darkEnabled: this.$store.state.darkEnabled
}
},
created () {
this.$vuetify.theme.dark = this.darkEnabled;
},
watch: {
'this.$store.state.darkEnabled'(oldValue, newValue) {
this.$vuetify.theme.dark = newValue;
}
}
}
最佳答案
观察者回调的第一个值是newValue。您的订单已发生变动并始终分配旧值。应该是 (newValue, oldValue)
另外,它应该是 '$store.state.darkEnabled'(newValue)
而不带 this
。
关于vue.js - Vuetifyjs 2.0 主题不会随着观察者的变化而改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57230173/