vue.js路由this.route.push跳轉頁面不刷新的解決辦法:使用【activated:{}】周期函數代替【mounted:{}】函數,代碼為【this.$router.go(0);】。

vue.js路由this.route.push跳轉頁面不刷新的解決辦法:
1、使用activated:{}周期函數代替mounted:{}函數即可。
2、監聽路由
// 不推薦、用戶體驗不好
watch: {
'$route' (to, from) {
// 路由發生變化頁面刷新
this.$router.go(0);
}
},
// 該方法會多一次請求
watch: {
'$route' (to, from) {
// 在mounted函數執行的方法,放到該處
this.qBankId = globalVariable.questionBankId;
this.qBankName = globalVariable.questionBankTitle;
this.searchCharpter();
}
},





