(vuex)动态监听state变化
/**/
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);
}