fix(vue-router): force chidren to be required if default child is present (#8394)

This commit is contained in:
Ahad Birang 2020-12-01 01:38:33 +03:30 committed by GitHub
parent 8e07cfc3b5
commit 7cac3c7fc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,6 +87,13 @@ function cleanChildrenRoutes (routes, isChild = false, routeNameSplitter = '-',
if (trailingSlash === false) { if (trailingSlash === false) {
defaultChildRoute.name = route.name defaultChildRoute.name = route.name
} }
route.children.forEach((child) => {
if (child.path !== indexRoutePath) {
const parts = child.path.split('/')
parts[1] = parts[1].endsWith('?') ? parts[1].substr(0, parts[1].length - 1) : parts[1]
child.path = parts.join('/')
}
})
delete route.name delete route.name
} }
route.children = cleanChildrenRoutes(route.children, true, routeNameSplitter, trailingSlash, routeName) route.children = cleanChildrenRoutes(route.children, true, routeNameSplitter, trailingSlash, routeName)