首页  >  问答  >  正文

保持在同一页面的 Vue.js 路由

<p>这是我第一次遇到这种情况,当我点击地址栏中的下一个按钮时,地址会发生变化,但页面仍然保持不变,就好像我没有点击下一个按钮一样。然而,新的步骤会显示在下面。希望有人能提供解决方案。提前感谢。</p> <pre class="brush:php;toolbar:false;"><template> <div> <button @click="send" >下一个</button> </div> </template> <script> methods:{ send(){ this.$router.push('/page/commande/1') } </script> //router { path:'/page/commande/1', name:'ConfirmationSend', component:() => import('../views/send.vue'), },</pre>
P粉904405941P粉904405941392 天前370

全部回复(1)我来回复

  • P粉762447363

    P粉7624473632023-08-26 00:56:22

    嘿,你应该将路由的完整路径(fullPath)作为路由视图(router-view)的key添加进去。这样只有在url参数改变时才会重新渲染页面/组件。

    <router-view :key='$route.fullPath' />

    回复
    0
  • 取消回复