Closed genffy closed 1 year ago
redirect: ({ matched }) => {
if (matched && matched.length > 0) {
if (matched[0].children && matched[0].children.length > 0) {
return matched[0].children[0]
}
}
// error page
return 'NoFind'
}
BTW: You can probably only return the name if there is one, it's safer than returning the record as otherwise it would fallback to checking the path
and if it contains params it will end up redirecting to something like /path/:id
redirect: ({ matched }) => {
if (matched && matched.length > 0) {
if (matched[0].children && matched[0].children.length > 0) {
return { name: matched[0].children[0].name }
}
}
// error page
return 'NoFind'
}
What problem is this solving
the scenario is the nest children routers have some biz logics to filter it such as menu auth. but now Redirct function params only have a to param.
Proposed solution
expect the redirect function add a children param for dynamic reach it nest children routes.
Describe alternatives you've considered
No response