Vue-router problem

problem description: is there any way that one router-link corresponds to one router-view

<div id="app">
  

<router-link to="/user/foo">/user/foo</router-link> <router-link to="/user/bar">/user/bar</router-link>

<!-- /user/foo --> <router-view></router-view> <!-- /user/bar --> <router-view></router-view> </div>

Link description

Apr.28,2021

add:
look at the specific code you provided and find that your foo bar is already param, so you can judge $route.params.id
if there are multiple routes that need to be determined to load with different router-view, you can define a meta parameter (if less, you can directly determine the route name)

path: '/user/foo',
                        name: 'foo',
                        component: foo,
                        meta: {
                            showview: 'left' //
                        }
                        
                        
                        
                        <router-view v-if="$route.meta.showview=='left'"></router-view>


                        <router-view v-if="$route.meta.showview=='right'"></router-view>

name the view. ide/essentials/named-views.html" rel=" nofollow noreferrer "> vue-router named view
does not apply to your example, which is essentially the same component with different parameters, although you can implement

by writing this way.
  <router-view v-if="$route.param.id === 'foo'"></router-view>
  <router-view v-if="$route.param.id === 'bar'"></router-view>

but it feels like it doesn't make sense at all

Menu