Geethu
Geethu

Reputation: 390

Switching between vue routes giving wrong urls

My current url is localhost:8000/admin/category/create

app.js

{   
    path : '/admin',
    component : dashboard
},
{
    name : 'list_category',
    path : '/admin/category',
    component : list_category
},
{
    name : 'show_category',
    path : '/admin/category/show/:id',          
    component : show_category
},
{
    name : 'create_category',
    path : '/admin/category/create',
    component : create_category
},
{
    name : 'edit_category',
    path : '/admin/category/edit/:id',
    component : edit_category
}

Upon navigating to list category from create category ie,

<router-link  class="btn btn-sm pull-right" to="admin/category"><strong>Category list</strong></router-link >

url becomes localhost:8000/admin/category/admin/category.

but what i need is this localhost:8000/admin/category route.

Thank you

Upvotes: 0

Views: 562

Answers (1)

Geethu
Geethu

Reputation: 390

Named vue route solved my issue

I changed

<router-link to="admin/catgeory" ><span>Artwork Category</span></router-link></li>

to

<router-link :to="{ name: 'list_category' }" ><span>Artwork Category</span></router-link></li>

Upvotes: 1

Related Questions