当Vuex中state数据发生改变的时候,如何在组件中监听到数据发生改变?

<script>
  export default {
     
    name: '',
    data() {
     
      return {
     }
    },
    watch:{
     
      '$store.state.orgid'(){
     
        alert('改变')
        this.initTable()
      }
    },
    methods: {
     
    //数据发生改变 触发的方法
      initTable(){
     }
    },
  }
</script>

你可能感兴趣的:(vue)