From: Alex Kyriakidis Date: Thu, 11 Feb 2021 18:41:15 +0000 (+0100) Subject: docs: improve 404 example (#769) X-Git-Tag: v4.0.4~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb5acb204f5b73c6e80b1604045049e97f7c9f31;p=thirdparty%2Fvuejs%2Frouter.git docs: improve 404 example (#769) --- diff --git a/docs/guide/essentials/dynamic-matching.md b/docs/guide/essentials/dynamic-matching.md index e24ae07d..62f1ed4c 100644 --- a/docs/guide/essentials/dynamic-matching.md +++ b/docs/guide/essentials/dynamic-matching.md @@ -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, }) ```