]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs: add removal of unnamed params
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 16 Oct 2020 07:39:56 +0000 (09:39 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 16 Oct 2020 07:40:09 +0000 (09:40 +0200)
docs/guide/migration/index.md
playground/router.ts

index 33dd30f02ba924d3895a7d162a37713a7225daf0..afc4c71e2a61ba0e43295273be7c8f40fa8794c1 100644 (file)
@@ -252,6 +252,18 @@ const parent = this.$route.matched[this.$route.matched.length - 2]
 
 The `pathToRegexpOptions` and `caseSensitive` properties of route records have been replaced with `sensitive` and `strict` options for `createRouter()`. They can now also be directly passed when creating the router with `createRouter()`. Any other option specific to `path-to-regexp` has been removed as `path-to-regexp` is no longer used to parse paths.
 
+### Removal of unnamed parameters
+
+Due to the removal of `path-to-regexp`, unnamed parameters are no longer supported:
+
+- `/foo(/foo)?/suffix` becomes `/foo/:_(foo)?/suffix`
+- `/foo(foo)?` becomes `/foo:_(foo)?`
+- `/foo/(.*)` becomes `/foo/:_(.*)`
+
+:::tip
+Note you can use any name instead of `_` for the param. The point is to provide one.
+:::
+
 ### Usage of `history.state`
 
 Vue Router saves information on the `history.state`. If you have any code manually calling `history.pushState()`, you should likely avoid it or refactor it with a regular `router.push()` and a `history.replaceState()`:
index 9a2a32b7526f9f350638a4ffc675467de8b08ed9..a98dddce0fade07fe1bc3d2db44f0dc11ec8ab1a 100644 (file)
@@ -37,6 +37,7 @@ export const router = createRouter({
     },
     { path: '/users/:id', name: 'user', component: User, props: true },
     { path: '/documents/:id', name: 'docs', component: User, props: true },
+    { path: '/optional/:id?', name: 'optional', component: User, props: true },
     { path: encodeURI('/n/€'), name: 'euro', component },
     { path: '/n/:n', name: 'increment', component },
     { path: '/multiple/:a/:b', name: 'multiple', component },