以下截圖,點擊左側不一樣的數據,右側根據左側的KEY動態加載數據。因爲右側是同一個頁面,在進行路由跳轉後,不會再次刷新數據。api
解決方案:異步
右側的頁面中 script代碼塊添加:watch模塊,以下代碼:this
... ...
mounted : function() { this.loadData(); }, watch: { //監聽相同路由下參數變化的時候,從而實現異步刷新 '$route'(to,from) { this.loadData(); }, }, methods: { loadData() { let varCode = this.$route.query.varCode; this.api.service .gets({ varCode: varCode }) .then(res => { console.log(res) }) }, ... ...