情况分析:路由参数获取现在生命周期里,多次进行参数切换,页面不能够实时监听,导致页面数据不更新,
解决办法:①使用watch对路由进行监听(推荐)
watch: {
// 方法1
'KaTeX parse error: Expected '}', got 'EOF' at end of input: …变化 if(this.route.params.articleId){
}
}
//方法2
'KaTeX parse error: Expected '}', got 'EOF' at end of input: …message = this.route.query.msg
}
}
}
②给router-view 加key 属性
3.beforeRouteEnter: (to, from, next) = > { // 写在当前组件
to.meta.keepAlive = false
next()
},
beforeRouteLeave: (to, from, next) = > { //写在前一个组件
to.meta.keepAlive = false
next()
},