diff --git a/src/components/Layout/Bread.js b/src/components/Layout/Bread.js index 0f11801..5a69607 100644 --- a/src/components/Layout/Bread.js +++ b/src/components/Layout/Bread.js @@ -24,6 +24,7 @@ const Bread = ({ menu, location }) => { } } + let paramMap = {} if (!current) { pathArray.push(menu[0] || { id: 1, @@ -36,6 +37,19 @@ const Bread = ({ menu, location }) => { }) } else { getPathArray(current) + + let keys = [] + let values = pathToRegexp(current.route, keys).exec(location.pathname.replace('#', '')) + + if (keys && values && (keys.length + 1) === values.length) { + keys.forEach((currentValue, index) => { + if (typeof currentValue.name !== 'string') { + return + } + + paramMap[currentValue.name] = values[index + 1] + }) + } } // 递归查找父级 @@ -48,7 +62,7 @@ const Bread = ({ menu, location }) => { return ( {((pathArray.length - 1) !== key) - ? + ? {content} : content}