From c2e70e54303f9a6c6ead9d18619551c4c447cf47 Mon Sep 17 00:00:00 2001 From: rickcole Date: Mon, 29 Jun 2020 19:03:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Scoped.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Scoped.tsx b/src/Scoped.tsx index cc74b97c8..ffe474b93 100644 --- a/src/Scoped.tsx +++ b/src/Scoped.tsx @@ -168,16 +168,17 @@ function createScopedTools( * * @param target 目标 name */ - close(target: string) { + close(target: string | boolean) { const scoped = this; let targets = typeof target === 'string' ? target.split(/\s*,\s*/) : target; // 过滤已经关掉的,当用户 close 配置多个弹框 name 时会出现这种情况 - targets - .map(name => scoped.getComponentByName(name)) - .filter(component => component && component.props.show) - .forEach(closeDialog); + Array.isArray(targets) && + targets + .map(name => scoped.getComponentByName(name)) + .filter(component => component && component.props.show) + .forEach(closeDialog); } }; } From 713a5bdb3f6811716356f1d6b420486b88854748 Mon Sep 17 00:00:00 2001 From: rickcole Date: Mon, 29 Jun 2020 19:06:14 +0800 Subject: [PATCH 2/2] fix --- src/Scoped.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Scoped.tsx b/src/Scoped.tsx index ffe474b93..11b20482e 100644 --- a/src/Scoped.tsx +++ b/src/Scoped.tsx @@ -170,15 +170,15 @@ function createScopedTools( */ close(target: string | boolean) { const scoped = this; - let targets = - typeof target === 'string' ? target.split(/\s*,\s*/) : target; - // 过滤已经关掉的,当用户 close 配置多个弹框 name 时会出现这种情况 - Array.isArray(targets) && - targets + if (typeof target === 'string') { + // 过滤已经关掉的,当用户 close 配置多个弹框 name 时会出现这种情况 + target + .split(/\s*,\s*/) .map(name => scoped.getComponentByName(name)) .filter(component => component && component.props.show) .forEach(closeDialog); + } } }; }