open matcher in router object #2067
Replies: 1 comment 1 reply
-
You can achieve this with named routes and a navigation guard because named routes skip parsing to match the route record. The actual code depends on what you need but usually the navigation guard will check if the id belongs to anything and redirect. That being said, I discourage you from having such URLs, they're usually confusing for a public-facing API and it's better to have a URL with the prefixes. Regarding the proposal. The matcher cannot be imported like that because it belongs to the router instance. It's currently private but it might be exposed in the future to let users provide their own version, the actual API will still go through a proper RFC with all the needed details |
Beta Was this translation helpful? Give feedback.
-
What problem is this solving
We are trying to support two kinds of page URLs without prefix
So any wildcard pages need to dynamic try the match in product categories, fallback to wildcard content pages if not matched.
I plan to change matcher behavior a bit but it's not opened in router object in latest 4.2.5 version (I use Nuxt3).
BTW I successfully did above feature before in Nuxt2 with old vue-router version.
Proposed solution
In createRouter return { currentRoute, matcher, ... }
Describe alternatives you've considered
No response
Beta Was this translation helpful? Give feedback.
All reactions