From d2ac91839a6f1c674ba56fc1f91b4af4863d244e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E4=BA=9A=E8=BE=89?= Date: Tue, 24 Oct 2017 18:55:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=A2=E5=8C=85=E5=B1=91=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E7=BA=A7=E5=8F=82=E6=95=B0=20?= =?UTF-8?q?=E4=BE=8B=EF=BC=9A=20=E5=BD=93=E5=89=8Drouter=E4=B8=BA/:appkey/?= =?UTF-8?q?:packageId=20=E7=88=B6=E7=BA=A7router=E4=B8=BA/:appkey=20?= =?UTF-8?q?=E5=BD=93=E5=89=8Dpathname=E4=B8=BA/com.mock.ly/58?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 可以看出appkey=com.mock.ly, packageId=58 目前这种场景下,面包屑中父级连接直接展示为/:appkey,没有解析 本次commit支持根据当前多param去填充面包屑中父级页面连接 --- src/components/Layout/Bread.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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}