Merge branch 'the-wang-master' into develop

This commit is contained in:
zuiidea
2017-10-30 11:28:23 +08:00
+15 -1
View File
@@ -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 (
<Breadcrumb.Item key={key}>
{((pathArray.length - 1) !== key)
? <Link to={item.route || '#'}>
? <Link to={pathToRegexp.compile(item.route)(paramMap) || '#'}>
{content}
</Link>
: content}