vue.js路由this.route.push跳转页面不刷新的解决办法:使用【activated:{}】周期函数代替【mounted:{}】函数,代码为【this.$router.go(0);】。

【相关文章推荐:vue.js】
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();
}
},相关免费学习推荐:JavaScript(视频)
以上就是vue.js路由this.route.push跳转页面不刷新怎么办的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号