Vue路由this.$router.push转跳同一个页面不刷新

不知道大家有没有遇到重复router.push进入同一个页面的时候虽然url传递的参数不一样但是页面并不会进行刷新。

<template>
  <el-container>
      <header></header>
    <el-main >
        <router-view :key="$route.fullPath"></router-view>
    </el-main>
      <footer></footer>
  </el-container>
</template>

可以在父组件中对 <router-view>标签(路由视图)绑定一个key,来给每个节点做一个唯一标识,这样就会更新DOM

猜你喜欢

转载自blog.csdn.net/weixin_44383354/article/details/107498529