在菜单的路由跳转上绑定一个随机query参数,例如时间戳或者随机数:

1 this.$router.push({
2     path:"/xxx",
3     query:{
4         t:Date.now(),
5     },
6 });

该操作会触发路由改变,但是组件内的状态没有初始化,因为组件没有被重建。

在路由容器上绑定key值:

1 <router-view :key="$route.path + $route.query.t"></router-view>

大功告成,通过key值的变化去强制刷新该组件。

原文链接:https://blog.csdn.net/CaanDoll/article/details/81429120

相关文章:

  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
相关资源
相似解决方案