vue.js路由this.route.push跳转页面不刷新怎么办

 451已收录

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


vue.js路由this.route.push跳转页面不刷新怎么办


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();
    }
},



本文网址:https://www.3ka.cn/server-3275.html
转载请声明来自:汇云资源网 - vue.js路由this.route.push跳转页面不刷新怎么办

评论(0)条

您还没有登录,请 登录 后发表评论!

提示:请勿发布广告垃圾评论,否则封号处理!!

    猜你喜欢