Comments (5)
By having only 2 optional parameters, the parser expects the path to have at least one character. It only makes it fully optional if it's only an optional param. So you can group both params into a single one or create an alias without the params. I'm curious to see what the real route is to see if this is worth supporting or if the alias solution is good enough. Can you please share that?
from router.
The real route is something like this: '/articles/:slug([\\w-]+-)?:article_id(\\d+)'
. The idea is to have optional slug for SEO and append id to it, so it should match
/articles/99
but also
/articles/new-vue-version-released-99
from router.
I realized the previous example doesn't have the optional id, sorry. That one is something like:
'users/:userId/videos/:slug([\\w-]+-)?:video_id(\\d+)?'
which should match
/users/1/videos/my-second-video-2
but also
/users/1/videos/2
It shows a list of videos in swipe screen, and optionally starts at the specific one based on video_id
from router.
I see. Thanks for sharing! Using an alias is indeed the correct solution
from router.
Ok, it would be useful to mention this in the docs, though. I broke a production for a few minutes, it's pretty unexpected behaviour. I'll submit a PR when I have some time to look into it
from router.
Related Issues (20)
- Regex in params extract extra characters with any capturing groups HOT 1
- Optional path segments HOT 4
- Router instance not found when testing component library integration
- hash decode not match the later encode HOT 2
- router.push with alias not changing original URL HOT 1
- Route Grouping HOT 1
- createMemoryHistory and createWebHistory differs with base HOT 1
- Optional parameters type missmatch on push and popstate back navigation HOT 1
- Default child not shown when using router-link with name instead of path HOT 3
- router.resolve doesn't include details of the query since 4.3.1
- Why does accessing base automatically add ‘/’ after the route? HOT 3
- Component cached even on a failed network request (vue-router v4.3.2) HOT 2
- Option to prevent adding the Hash (#/) for the Initial route HOT 2
- Parent navigation guard inconsistently re-run when redirecting between child routes HOT 8
- useRouter() returns undefined when uses in setup() method in Options API component HOT 2
- External Type Declaration Causing Inability to Pass certain Route Parameter as Prop in Vue Router 4 HOT 1
- Error: Missing required param HOT 2
- Introduce `createSearchParamsHistory` HOT 1
- Introduce `elementTargetClass` option (alternative to `:target`) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from router.