]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs: improve 404 example (#769)
authorAlex Kyriakidis <hootlex@icloud.com>
Thu, 11 Feb 2021 18:41:15 +0000 (19:41 +0100)
committerGitHub <noreply@github.com>
Thu, 11 Feb 2021 18:41:15 +0000 (19:41 +0100)
docs/guide/essentials/dynamic-matching.md

index e24ae07db23395d4807176e911bf44c3483f910b..62f1ed4c09adfe2a23807eb82f99d95031a7fa99 100644 (file)
@@ -93,7 +93,11 @@ In this specific scenario we are using a [custom regexp](/guide/essentials/route
 ```js
 this.$router.push({
   name: 'NotFound',
-  params: { pathMatch: this.$route.path.split('/') },
+  // preserve current path and remove the first char to avoid the target URL starting with `//`
+  params: { pathMatch: this.$route.path.substring(1).split('/') },
+  // preserve existing query and hash if any
+  query: this.$route.query,
+  hash: this.$route.hash,
 })
 ```