You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this scenario, when visiting /child, useRoute().meta.title will be "Child" everywhere in the app. But sometimes we need to get access to the relative information within the Parent and Child component. The question is is there anything else needed from route records besides meta?
To currently access this information, we need to index the route.matched array with the depth of the current view. Usually, you know this information within the component (as a hardcoded number) but that's not always the case, so we can instead inject the depth of the current view with viewDepthKey (https://github.com/vuejs/router/blob/main/src/index.ts#L29) or directly the matchedRouteKey with something like:
When dealing with nested routes, it is often useful to access information relative to a specific route record:
In this scenario, when visiting
/child
,useRoute().meta.title
will be "Child" everywhere in the app. But sometimes we need to get access to the relative information within the Parent and Child component. The question is is there anything else needed from route records besidesmeta
?To currently access this information, we need to index the
route.matched
array with the depth of the current view. Usually, you know this information within the component (as a hardcoded number) but that's not always the case, so we can instead inject the depth of the current view withviewDepthKey
(https://github.com/vuejs/router/blob/main/src/index.ts#L29) or directly thematchedRouteKey
with something like:This could also be exposed directly in
<RouterView>
s slot:meta
directly instead?From
The text was updated successfully, but these errors were encountered: