From b3af8f8570b4aaaa55c93c9023b356a81f4d45c5 Mon Sep 17 00:00:00 2001 From: jim Date: Wed, 7 Feb 2018 14:45:05 +0800 Subject: [PATCH] fix #821 Menu selection problem --- .gitignore | 1 + src/components/SiderMenu/SiderMenu.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index aa3fce58..409be881 100755 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ yarn.lock package-lock.json *bak jsconfig.json +.prettierrc diff --git a/src/components/SiderMenu/SiderMenu.js b/src/components/SiderMenu/SiderMenu.js index 5ddf6ed9..4811894d 100644 --- a/src/components/SiderMenu/SiderMenu.js +++ b/src/components/SiderMenu/SiderMenu.js @@ -87,12 +87,12 @@ export default class SiderMenu extends PureComponent { } /** * Get selected child nodes - * /user/chen => /user/:id + * /user/chen => ['user','/user/:id'] */ getSelectedMenuKeys = (path) => { const flatMenuKeys = this.getFlatMenuKeys(this.menus); return flatMenuKeys.filter((item) => { - return pathToRegexp(`/${item}`).test(path); + return pathToRegexp(`/${item}(.*)`).test(path); }); } /** -- GitLab