vue router 同一頁面不刷新的問題

1,使用key 

在router-view設置動態的key就會每次都刷新了

<router-view :key="$route.params.Id" />

2,使用beforeRouteUpdate

beforeRouteUpdate(to, from, next) {
    console.log(to, from);
    next();
  },

官網地址:https://router.vuejs.org/zh/guide/essentials/dynamic-matching.html#%E5%93%8D%E5%BA%94%E8%B7%AF%E7%94%B1%E5%8F%82%E6%95%B0%E7%9A%84%E5%8F%98%E5%8C%96

發佈了105 篇原創文章 · 獲贊 22 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章