Commit 3de47dd15e76a7a79456b70e3656a9eeced03ef3
Committed by
GitHub
Merge pull request #4575 from RenShine/2.0
fixed bug #4466 #4300
Showing
2 changed files
with
18 additions
and
2 deletions
Show diff stats
examples/routers/select.vue
... | ... | @@ -7,6 +7,8 @@ |
7 | 7 | <Select v-model="model2" multiple style="width:200px"> |
8 | 8 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> |
9 | 9 | </Select> |
10 | + | |
11 | + <Button type="primary" @click="changeData">changeData</Button> | |
10 | 12 | </div> |
11 | 13 | </template> |
12 | 14 | <script> |
... | ... | @@ -42,6 +44,11 @@ |
42 | 44 | model1: '', |
43 | 45 | model2: [] |
44 | 46 | } |
47 | + }, | |
48 | + methods: { | |
49 | + changeData() { | |
50 | + this.model2.push('Canberra') | |
51 | + } | |
45 | 52 | } |
46 | 53 | } |
47 | 54 | </script> | ... | ... |
src/components/select/select.vue
... | ... | @@ -135,6 +135,15 @@ |
135 | 135 | return textContent || (typeof innerHTML === 'string' ? innerHTML : ''); |
136 | 136 | }; |
137 | 137 | |
138 | + const checkValuesNotEqual = (value,publicValue,values) => { | |
139 | + const strValue = JSON.stringify(value); | |
140 | + const strPublic = JSON.stringify(publicValue); | |
141 | + const strValues = JSON.stringify(values.map( item => { | |
142 | + return item.value; | |
143 | + })); | |
144 | + return strValue !== strPublic || strValue !== strValues || strValues !== strPublic; | |
145 | + }; | |
146 | + | |
138 | 147 | |
139 | 148 | const ANIMATION_TIMEOUT = 300; |
140 | 149 | |
... | ... | @@ -653,12 +662,12 @@ |
653 | 662 | }, |
654 | 663 | watch: { |
655 | 664 | value(value){ |
656 | - const {getInitialValue, getOptionData, publicValue} = this; | |
665 | + const {getInitialValue, getOptionData, publicValue, values} = this; | |
657 | 666 | |
658 | 667 | this.checkUpdateStatus(); |
659 | 668 | |
660 | 669 | if (value === '') this.values = []; |
661 | - else if (JSON.stringify(value) !== JSON.stringify(publicValue)) { | |
670 | + else if (checkValuesNotEqual(value,publicValue,values)) { | |
662 | 671 | this.$nextTick(() => this.values = getInitialValue().map(getOptionData).filter(Boolean)); |
663 | 672 | } |
664 | 673 | }, | ... | ... |