判断逻辑优化一下

This commit is contained in:
rickcole 2020-06-29 19:03:32 +08:00
parent 3981ab9f8d
commit 5c3b8888f5
1 changed files with 6 additions and 5 deletions

View File

@ -168,16 +168,17 @@ function createScopedTools(
* *
* @param target name * @param target name
*/ */
close(target: string) { close(target: string | boolean) {
const scoped = this; const scoped = this;
let targets = let targets =
typeof target === 'string' ? target.split(/\s*,\s*/) : target; typeof target === 'string' ? target.split(/\s*,\s*/) : target;
// 过滤已经关掉的,当用户 close 配置多个弹框 name 时会出现这种情况 // 过滤已经关掉的,当用户 close 配置多个弹框 name 时会出现这种情况
targets Array.isArray(targets) &&
.map(name => scoped.getComponentByName(name)) targets
.filter(component => component && component.props.show) .map(name => scoped.getComponentByName(name))
.forEach(closeDialog); .filter(component => component && component.props.show)
.forEach(closeDialog);
} }
}; };
} }