Skip to content Skip to sidebar Skip to footer

Vuerouter Default Child Route Without Trailing Slash

VueRouter always adds a trailing slash before the path of the child route. So lets say I have a route config like this: const routes = [ path: '/home', components: {

Solution 1:

I've tried next structure which worked for me:

constroutes= [
    path:'/home',
    components: {
        default:HomeBase
    },
    children: [
        {
            path:'/home',
            component:HomeIndex,
            name:"homeindex"
        },
        {
            path:':aid',
            component:HomeArticle,
            name:"aid"
        }
    ]
]

Here is the working fiddle

Using versions: Vue - 2.5.2, vue-router - 3.0.1. Routing works both using name and path without adding trailing slash at the end, i.e.:

this.$router.push({name: "homeindex"})

this.$router.push("/home")

Post a Comment for "Vuerouter Default Child Route Without Trailing Slash"