Commit d1038fce2632a20c79683fe66e35b04f372f6b23
Committed by
GitHub

Merge pull request #3699 from luffyzhao/select-binding-0
解决select 默认数据不能绑定0的情况
Showing
1 changed file
with
4 additions
and
2 deletions
Show diff stats
src/components/select/select.vue
@@ -410,8 +410,10 @@ | @@ -410,8 +410,10 @@ | ||
410 | getInitialValue(){ | 410 | getInitialValue(){ |
411 | const {multiple, value} = this; | 411 | const {multiple, value} = this; |
412 | let initialValue = Array.isArray(value) ? value : [value]; | 412 | let initialValue = Array.isArray(value) ? value : [value]; |
413 | - if (!multiple && (typeof initialValue[0] === 'undefined' || String(initialValue[0]).trim() === '')) initialValue = []; | ||
414 | - return initialValue.filter(Boolean); | 413 | + if (!multiple && (typeof initialValue[0] === 'undefined' || (String(initialValue[0]).trim() === '' && !Number.isFinite(initialValue[0])))) initialValue = []; |
414 | + return initialValue.filter((item) => { | ||
415 | + return Boolean(item) || item === 0 | ||
416 | + }); | ||
415 | }, | 417 | }, |
416 | processOption(option, values, isFocused){ | 418 | processOption(option, values, isFocused){ |
417 | if (!option.componentOptions) return option; | 419 | if (!option.componentOptions) return option; |