From 121ffbd8fdc91a3814bd931bd35eded1aca7bca2 Mon Sep 17 00:00:00 2001 From: Baran Elitez <baranelitez@gmail.com> Date: Wed, 16 Dec 2020 14:13:29 +0300 Subject: [PATCH] Update dynamic-matching.md The docs never mention optional parameters for paths. --- docs/guide/essentials/dynamic-matching.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/guide/essentials/dynamic-matching.md b/docs/guide/essentials/dynamic-matching.md index 15bcdfca4..52a6d9486 100644 --- a/docs/guide/essentials/dynamic-matching.md +++ b/docs/guide/essentials/dynamic-matching.md @@ -29,6 +29,19 @@ const User = { You can check out a live example [here](https://jsfiddle.net/yyx990803/4xfa2f19/). + +You can make a parameter optional by adding `?` to the end of the parameter. + +```js +const router = new VueRouter({ + routes: [ + // + { path: '/user/:id?', component: Users } + ] +}) +``` + + You can have multiple dynamic segments in the same route, and they will map to corresponding fields on `$route.params`. Examples: | pattern | matched path | \$route.params |