“Watch toko Vuex” Kode Jawaban

Watch toko Vuex

import { mapState } from 'vuex';

export default {
    computed: {
        ...mapState(['somestate']),
        someComputedLocalState() {
            // is triggered whenever the store state changes
            return this.somestate + ' works too';
        }
    },
    watch: {
        somestate(val, oldVal) {
            // is triggered whenever the store state changes
            console.log('do stuff', val, oldVal);
        }
    }
}
Yawning Yak

Watch toko Vuex

watch: {
  '$store.state.drawer': function() {
    console.log(this.$store.state.drawer)
  }
}
Yawning Yak

Watch toko Vuex

computed: {
    ...mapState({
        // to access local state with `this`, a normal function must be used
        countPlusLocalState (state) {
          return state.count + this.localCount
        }
    }
})
Yawning Yak

Jawaban yang mirip dengan “Watch toko Vuex”

Pertanyaan yang mirip dengan “Watch toko Vuex”

Lebih banyak jawaban terkait untuk “Watch toko Vuex” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya