-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72a052f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
I'm migrating a Vue 2 app to Vue 3 ans this completely broke the app.
If I understand correctly, there is no way to define a meta only for a route (and not its children) ?
For example, I'm using the meta field to know if a route should be authenticated or not, and this break the whole app since the root page is public (and propagate "public: true" to all children).
Another example: I was also using
{ ignore: true }
that, when present, prevented to go to the route (withnext(false)
in guard), and this also broken all children routes.Could we imagine a way to not propagate some meta ?
Thank you.
72a052f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can still go through
matched[x].meta
to check any specific meta field.Another solution is overriding the meta property in children declaration:
72a052f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having to pass all metas to all children is really annoying. That means we are no longer able to have a default value for meta (
const foo = to.meta.foo || 'My value'
)I'm also using meta for optional page title, "reload profile" flag for some page and so on...
Thanks for the
matched
trick, I'll stick to this for now, but it feel a little hacky.I searched the tickets, I'm surprised I seem to be the only one who doesn't want to propagate the meta ^^
Again, thank you.
72a052f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, most people prefer to merge meta rather than going through the
matched
array. It's not hacky, it's fine to use.