(vuex)动态监听state变化

时间:2024-11-18 09:17:35
/**/ const state={ existSSID:{}, wifiList:[] }; const getters={ getWiFiList: state => { return state.wifiList; } }; export default new Vuex.Store({ state, getters, mutations, actions }); /*在需要监听的文件中*/ computed:{ ...mapGetters([ 'getWiFiList' ]) }, watch: { getWiFiList: function(li) { //li就是改变后的wifiList值 this.getAllId(li); //调用别的函数 console.log("改变",li); }