From ffeb6565051116a2e86e1382efd8b0b050cb1507 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sat, 19 Sep 2020 06:29:05 +0800 Subject: [PATCH] fix(cli): vue-router catchAll usage --- packages/vant-cli/site/desktop/router.js | 6 ++++-- packages/vant-cli/site/mobile/router.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/vant-cli/site/desktop/router.js b/packages/vant-cli/site/desktop/router.js index fd758e4e5..56d3e41c7 100644 --- a/packages/vant-cli/site/desktop/router.js +++ b/packages/vant-cli/site/desktop/router.js @@ -47,12 +47,14 @@ function getRoutes() { if (locales) { routes.push({ - path: '/:catchAll(.*)', + name: 'notFound', + path: '/:path(.*)+', redirect: (route) => `/${getLangFromRoute(route)}/`, }); } else { routes.push({ - path: '/:catchAll(.*)', + name: 'notFound', + path: '/:path(.*)+', redirect: '/', }); } diff --git a/packages/vant-cli/site/mobile/router.js b/packages/vant-cli/site/mobile/router.js index 28444db4d..0ca5c4568 100644 --- a/packages/vant-cli/site/mobile/router.js +++ b/packages/vant-cli/site/mobile/router.js @@ -28,7 +28,8 @@ function getRoutes() { if (langs.length) { routes.push({ - path: '/:catchAll(.*)', + name: 'NotFound', + path: '/:path(.*)+', redirect: (route) => `/${getLangFromRoute(route)}/`, }); @@ -41,7 +42,8 @@ function getRoutes() { }); } else { routes.push({ - path: '/:catchAll(.*)', + name: 'NotFound', + path: '/:path(.*)+', redirect: () => '/', });