Skip to content

How to access parameters of multiple nested routes? #486

Closed Answered by posva
adamdehaven asked this question in Q&A
Discussion options

You must be logged in to vote

Technically, you shouldn't use a param from a deeper view: why should that view be aware of it? Maybe the nested routing wasn't needed and you just wanted to split your page component into multiple ones.

You guess right, you can do what you wanted, you just used the or bitwise operator instead of thy TS union one:

const route = useRoute('' as 'products-product_id' | 'products-product_id-versions-version_id')

This would be a more realistic type that would allow you to write something like:

<MyComp v-if="'productId' in route.params'" :productId="route.params.productIt" />

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@adamdehaven
Comment options

Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants