From 69571f2916a7907aebbbfc7f8e4c01ad53a6304a Mon Sep 17 00:00:00 2001 From: DosLin Date: Mon, 25 Jun 2018 10:53:10 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E4=BF=AE=E6=94=B9=E7=88=B6ID=E5=8F=96?= =?UTF-8?q?=E5=80=BC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Layout/Menu.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/Layout/Menu.js b/src/components/Layout/Menu.js index 1e1ec42a..0ce46ab9 100644 --- a/src/components/Layout/Menu.js +++ b/src/components/Layout/Menu.js @@ -98,8 +98,12 @@ const Menus = ({ let result = [String(current[id])] const getPath = (item) => { if (item && item[pid]) { - result.unshift(String(item[pid])) - getPath(queryArray(array, item[pid], id)) + if (item[pid] === '-1') { + result.unshift(String(item['bpid'])) + } else { + result.unshift(String(item[pid])) + getPath(queryArray(array, item[pid], id)) + } } } getPath(current) @@ -111,8 +115,6 @@ const Menus = ({ if (!defaultSelectedKeys) { defaultSelectedKeys = ['1'] - } else if(defaultSelectedKeys[0] === '-1') { - defaultSelectedKeys = [defaultSelectedKeys[1].toString()[0]] } return (