vue中刷新当前页步骤:
store.js文件
state:{
refreshBtnTime:123
}
mutations:{
updataRefreshBtnTime(state,value){
state.refreshBtnTime = value;
}
}
刷新按钮所在文件student.vue
methods:{
refreshBtn(){
this.$store.commit('updataRefreshBtnTime',Date.now());
}
}
要刷新的页面addclass.vue
computed:{
refreshTime(){return this.$store.state.refreshBtnTime}
}
watch:{refreshTime(){this.loadData()}} //this.loadData()是要刷新的页面的请求方法