Skip to content

Proper Use of route() in Composition API/SFC #492

Answered by bakerkretzmar
andrewskm asked this question in Q&A
Discussion options

You must be logged in to vote

Inside your templates you should be able to keep using route() normally, and if you're using the @routes Blade directive then route() should actually also be available globally, which means you can use it directly even in the setup() function.

I didn't know about getCurrentInstance(), if that works then I think it's totally fine to do that.

Otherwise, you can import route in each component and just use it like a regular function, see #454 (comment) for some detailed examples. We're planning to provide a useRoute() hook eventually to make this easier too.

Replies: 2 comments 13 replies

Comment options

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

Answer selected by andrewskm
Comment options

You must be logged in to vote
12 replies
@livevsonline
Comment options

@romsar
Comment options

@livevsonline
Comment options

@livevsonline
Comment options

@romsar
Comment options

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