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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章