顶端通知组件
//监听计数器有变化则重新请求后端
watch: {
'$store.state.app.refreshCount': function () {
this.loadData()
},
},
状态管理配置 store
state: {
refreshCount: 0
},
mutations: {
SET_REFRESH_COUNT (state, refreshCount) {
state.refreshCount = state.refreshCount + 1
}
},
//更新计数器
actions: {
ToggleRefreshCount({ commit }, refreshCount) {
commit('SET_REFRESH_COUNT', refreshCount)
},
}
和站内信相关的页面
//一旦更新数据 则更新状态 使顶部通知组件监听到变化
this.$store.dispatch('ToggleRefreshCount')