From cb5acb204f5b73c6e80b1604045049e97f7c9f31 Mon Sep 17 00:00:00 2001 From: Alex Kyriakidis Date: Thu, 11 Feb 2021 19:41:15 +0100 Subject: [PATCH] docs: improve 404 example (#769) --- docs/guide/essentials/dynamic-matching.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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, }) ``` -- 2.47.3