fix:修复options数据为空时报错问题 (#2317)

Co-authored-by: qinhaoyan <qinhaoyan@baidu.com>
This commit is contained in:
qinhaoyan 2021-07-23 16:09:26 +08:00 committed by GitHub
parent 584187a902
commit 9d660f8a91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -298,7 +298,7 @@ export function registerOptionsControl(config: OptionsConfig) {
() => this.forceUpdate()
);
// 默认全选。这里会和默认值\回填值逻辑冲突所以如果有配置source则不执行默认全选
if (multiple && defaultCheckAll && options.length && !source) {
if (multiple && defaultCheckAll && formItem.filteredOptions?.length && !source) {
this.defaultCheckAll();
}
}
@ -721,7 +721,7 @@ export function registerOptionsControl(config: OptionsConfig) {
@autobind
async initOptions(data: any) {
await this.reloadOptions(false, true);
const {formItem, name, multiple, defaultCheckAll, options} = this.props;
const {formItem, name, multiple, defaultCheckAll} = this.props;
if (!formItem) {
return;
}
@ -730,7 +730,7 @@ export function registerOptionsControl(config: OptionsConfig) {
}
// 默认全选
if (multiple && defaultCheckAll && options.length) {
if (multiple && defaultCheckAll && formItem.filteredOptions?.length) {
this.defaultCheckAll();
}
}