Merge pull request #3699 from luffyzhao/select-binding-0

解决select 默认数据不能绑定0的情况
This commit is contained in:
Aresn 2018-05-28 09:02:53 +08:00 committed by GitHub
commit d1038fce26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -410,8 +410,10 @@
getInitialValue(){ getInitialValue(){
const {multiple, value} = this; const {multiple, value} = this;
let initialValue = Array.isArray(value) ? value : [value]; let initialValue = Array.isArray(value) ? value : [value];
if (!multiple && (typeof initialValue[0] === 'undefined' || String(initialValue[0]).trim() === '')) initialValue = []; if (!multiple && (typeof initialValue[0] === 'undefined' || (String(initialValue[0]).trim() === '' && !Number.isFinite(initialValue[0])))) initialValue = [];
return initialValue.filter(Boolean); return initialValue.filter((item) => {
return Boolean(item) || item === 0
});
}, },
processOption(option, values, isFocused){ processOption(option, values, isFocused){
if (!option.componentOptions) return option; if (!option.componentOptions) return option;