N
Nuxt7mo ago
owljackob

Pass property using navigateTo

I have a list where each item is clickable. I would like to pass a property (string) that has been fetched and pass it to the page that navigateTo navigates. It's [...slug] and I would like to access that property there (if value exists). Could anyone please give me a hint how to achieve that?
6 Replies
CentyPoo
CentyPoo7mo ago
Sounds like you just want to add a query param to the navigateTo?
owljackob
owljackobOP7mo ago
Thank you for the reply. This approach won't work sadly because the string has some words... so I believe that the URL limit would be reached (in some cases). Sorry for not including that inside of the question.
CentyPoo
CentyPoo7mo ago
Hmm maybe useState may be the easiest option? There's no other way through navigateTo as far as I'm aware
pyplacca
pyplacca7mo ago
you can use route states;
// PS: passing reactive values into the state might lead to unexpected behaviour and likely not be included in the state.
navigateTo({path: '/', state: {/* your data or property */}})
// PS: passing reactive values into the state might lead to unexpected behaviour and likely not be included in the state.
navigateTo({path: '/', state: {/* your data or property */}})
this state can then be accessed from;
useRouter().options.history.state
useRouter().options.history.state
Omnislash
Omnislash7mo ago
That's nice I didn't know that thank you !
owljackob
owljackobOP7mo ago
Perfect. Thank you! ❤️
Want results from more Discord servers?
Add your server