【问题标题】:Vue <router-link> inside the child <router-view> component doesn't update the parent component子 <router-view> 组件内的 Vue <router-link> 不会更新父组件
【发布时间】:2020-05-19 14:19:27
【问题描述】:

我在我的 Vue 应用程序中使用 &lt;router-view&gt; 进行嵌套路由。 子组件有一个链接组件,当我点击链接时,它不会更新父组件,只会更新子组件。 有谁知道如何解决这个问题?

路由器.js

...
{
  path: 'companies/:id',
  component: () => import('.../companies/view/index'),
  children: [
    {
      path: 'info',
      component: () => import('.../companies/view/info'),
    },
    {
      path: 'address',
      component: () => import('.../companies/view/address'),
    }
  ]
...

我将&lt;router-view&gt; 组件放在 index.vue 文件中以显示信息和地址组件。

在 info.vue 中,

<router-link to="companies/11/address">address</router-link>

【问题讨论】:

  • 你应该显示你的代码的相关部分

标签: vue.js vue-component vue-router nested-routes


【解决方案1】:

Vue Routing - Reacting to Params Changes

应该在路由参数更改时更新组件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-02
    • 2022-01-25
    • 2020-09-06
    • 2018-11-08
    • 1970-01-01
    • 2018-04-22
    • 2017-03-06
    • 2021-06-11
    相关资源
    最近更新 更多