Reputation: 31
I want to use the same component for the different routes i.e - I have 2 routes
Now I want to render the same component if a user visits one of the above route. I tried the below code and it's working fine for me, but it's not the proper solution. Is there any way to achieve in a single route?
<script>
{
path: ':id',
component: () => import('@/views/Users')
},
{
path: ':id/:user_id',
component: () => import('@/views/Users')
}
<script>
Upvotes: 0
Views: 668
Reputation: 50767
You can declare an optional argument:
{
path: '/users/:id/:user_id?',
component: () => import('@/views/Users')
}
This will work for /users/39
and /users/39/58
Upvotes: 3