1.監聽路由處理
watch: { $route(to, from) { // 邏輯
// 重新調用數據接口
} },
2.beforeRouteUpdate導航守衛 路由更新時觸發
beforeRouteUpdate (to, from, next) { // 邏輯 this.$route.query.xx = to.params.xx; next() // 一定要有next },
3.只需要在入口文件設置監聽事件即可
<div id="app" :key="Key">
</div> data() { return { Key: '' }; }, watch: { $route: function(newUrl, oldUrl) { this.Key = new Date().getTime(); } }