From 8924573414202d0755d61dccc2711cdfefbbf6d4 Mon Sep 17 00:00:00 2001 From: yoyo837 Date: Tue, 14 Aug 2018 19:23:20 +0800 Subject: [PATCH] for in --- src/layouts/BasicLayout.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 781d6dbd..cfdfa277 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -132,10 +132,14 @@ export default class BasicLayout extends React.PureComponent { const { routerData, location } = this.props; const { pathname } = location; let title = 'Ant Design Pro'; + let currRouterData = null; // match params path - const currRouterData = (Object.entries(routerData).find(([key]) => - pathToRegexp(key).test(pathname) - ) || [])[1]; + for (key in Object.keys(routerData)) { + if (pathToRegexp(key).test(pathname)) { + currRouterData = routerData[key]; + break + } + } if (currRouterData && currRouterData.name) { title = `${currRouterData.name} - Ant Design Pro`; } -- GitLab