Vue.js - update router view

后端 未结 2 478
再見小時候
再見小時候 2020-12-12 00:25

I am new to Vue.js and encountered this problem.

I have this simple piece of code in App.vue

相关标签:
2条回答
  • 2020-12-12 01:08

    You need to include props: true

    {
        path: '/brand/:brandId',
        props: true,
        name: 'brand',
        component: () => import('../views/BrandDetail.vue')
    }
    
    0 讨论(0)
  • 2020-12-12 01:17

    This happens when you enter a route you are already on, and the component is not reloaded, even though the parameters are different. Change your router-view to:

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

    Vue tries to reuse components when possible, which is not what you want in this situation. The key attribute tells Vue to use a different instance of a component for each unique key rather than reusing one. Since the path is different for each set of parameters, that will make a good key.

    0 讨论(0)
提交回复
热议问题