feat(router): add "paramsInheritanceStrategy" router configuration option
Previously, the router would merge path and matrix params, as well as data/resolve, with special rules (only merging down when the route has an empty path, or is component-less). This change adds an extra option "paramsInheritanceStrategy" which, when set to 'always', makes child routes unconditionally inherit params from parent routes. Closes #20572.
This commit is contained in:

committed by
Alex Rickabaugh

parent
5f23a1223f
commit
5efea2f6a0
@ -278,6 +278,16 @@ export interface ExtraOptions {
|
||||
* current URL. Default is 'ignore'.
|
||||
*/
|
||||
onSameUrlNavigation?: 'reload'|'ignore';
|
||||
|
||||
/**
|
||||
* Defines how the router merges params, data and resolved data from parent to child
|
||||
* routes. Available options are:
|
||||
*
|
||||
* - `'emptyOnly'`, the default, only inherits parent params for path-less or component-less
|
||||
* routes.
|
||||
* - `'always'`, enables unconditional inheritance of parent params.
|
||||
*/
|
||||
paramsInheritanceStrategy?: 'emptyOnly'|'always';
|
||||
}
|
||||
|
||||
export function setupRouter(
|
||||
@ -314,6 +324,10 @@ export function setupRouter(
|
||||
router.onSameUrlNavigation = opts.onSameUrlNavigation;
|
||||
}
|
||||
|
||||
if (opts.paramsInheritanceStrategy) {
|
||||
router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;
|
||||
}
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user