Programing

Vuetifyjs 2.0 테마는 관찰자에 따라 변경되지 않음

c10106 2022. 4. 13. 20:54
반응형

Vuetifyjs 2.0 테마는 관찰자에 따라 변경되지 않음

Vuetifyjs v1.5와 함께 나는 vue watchers를 사용하여 주제를 동적으로 변경할 수 있었다.Vuetifyjs 2.0에서는 더 이상 작동하지 않음

Vue 버전: 2.6.10 Vuetify: 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.

참조URL: https://stackoverflow.com/questions/57230173/vuetifyjs-2-0-theme-doesnt-change-with-watchers

반응형