fix(vue): correctly pass route props to components (#22476)

resolves #22472
This commit is contained in:
Liam DeBeasi
2020-11-11 12:12:12 -05:00
committed by GitHub
parent a4a64530ff
commit 0956f8bc55
4 changed files with 154 additions and 8 deletions

View File

@ -355,15 +355,36 @@ export const IonRouterOutlet = defineComponent({
{ ref: 'ionRouterOutlet' },
// TODO types
components && components.map((c: any) => {
let props = {
ref: c.vueComponentRef,
key: c.pathname,
isInOutlet: true,
registerIonPage: (ionPageEl: HTMLElement) => registerIonPage(c, ionPageEl)
}
/**
* IonRouterOutlet does not support named outlets.
*/
if (c.matchedRoute?.props?.default) {
const matchedRoute = c.matchedRoute;
const routePropsOption = matchedRoute.props.default;
const routeProps = routePropsOption
? routePropsOption === true
? c.params
: typeof routePropsOption === 'function'
? routePropsOption(matchedRoute)
: routePropsOption
: null
props = {
...props,
...routeProps
}
}
return h(
c.vueComponent,
{
ref: c.vueComponentRef,
key: c.pathname,
isInOutlet: true,
registerIonPage: (ionPageEl: HTMLElement) => registerIonPage(c, ionPageEl)
}
)
props
);
})
)
}