From 034b8b02cecf466dd5d6baa32092145dfc633599 Mon Sep 17 00:00:00 2001 From: qiuzuhui Date: Mon, 12 Apr 2021 17:45:06 +0800 Subject: [PATCH 1/2] fix: replace existing route in addRoute show warning msg --- src/create-route-map.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/create-route-map.js b/src/create-route-map.js index 93a558f8a..09d2372e0 100644 --- a/src/create-route-map.js +++ b/src/create-route-map.js @@ -144,10 +144,8 @@ function addRouteRecord ( }) } - if (!pathMap[record.path]) { - pathList.push(record.path) - pathMap[record.path] = record - } + pathList.push(record.path) + pathMap[record.path] = record if (route.alias !== undefined) { const aliases = Array.isArray(route.alias) ? route.alias : [route.alias] @@ -178,9 +176,8 @@ function addRouteRecord ( } if (name) { - if (!nameMap[name]) { - nameMap[name] = record - } else if (process.env.NODE_ENV !== 'production' && !matchAs) { + nameMap[name] = record + if (!nameMap[name] && process.env.NODE_ENV !== 'production' && !matchAs) { warn( false, `Duplicate named routes definition: ` + From d2f113e8c8680179852dc16a70815283baaf8b02 Mon Sep 17 00:00:00 2001 From: qiuzuhui Date: Mon, 12 Apr 2021 21:31:10 +0800 Subject: [PATCH 2/2] fix: replace existing route in addRoute show warning msg --- src/create-route-map.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/create-route-map.js b/src/create-route-map.js index 09d2372e0..09c90a0ec 100644 --- a/src/create-route-map.js +++ b/src/create-route-map.js @@ -144,7 +144,9 @@ function addRouteRecord ( }) } - pathList.push(record.path) + if (!pathMap[record.path]) { + pathList.push(record.path) + } pathMap[record.path] = record if (route.alias !== undefined) {