注意:created()方法是无效的
方法:在需要刷新的页面添加以下内容
解决办法有两种:
1、使用activated:{}周期函数代替mounted:{}函数即可。
将mounted函数 替换成activated函数。
mounted(){
在这里插入代码片
}
==》
activated(){
在这里插入代码片
}
2、监听路由
第二种:通过路由监听的方法。将mounted下的方法函数放到watch路由下
// 不推荐、用户体验不好
watch: {
'$route' (to, from) {
// 路由发生变化页面刷新
this.$router.go(0);
}
},
// 该方法会多一次请求
watch: {
'$route' (to, from) {
// 在mounted函数执行的方法,放到该处
this.qBankId = globalVariable.questionBankId;
this.qBankName = globalVariable.questionBankTitle;
this.searchCharpter();
}
},
最后为了方便大家的沟通与交流请加QQ群: 625787746
请进QQ群交流:【IT博客技术分享群①】:https://jq.qq.com/?_wv=1027&k=DceI0140