Commit 5dc44ccf9b3fc19df3a758901f0bdd5020953bf8
1 parent
a73ae72b
fixed #2793
Showing
2 changed files
with
16 additions
and
13 deletions
Show diff stats
examples/routers/cascader.vue
1 | <template> | 1 | <template> |
2 | - <Cascader v-model="value3" :data="data" filterable @on-change="hc"></Cascader> | 2 | + <div style="margin: 100px;width: 300px;"> |
3 | + <Cascader v-model="value" :data="data" change-on-select></Cascader> | ||
4 | + </div> | ||
3 | </template> | 5 | </template> |
4 | <script> | 6 | <script> |
5 | export default { | 7 | export default { |
6 | data () { | 8 | data () { |
7 | return { | 9 | return { |
8 | - data: [{ | 10 | + value: ['beijing', 'gugong'], |
11 | + data: [] | ||
12 | + } | ||
13 | + }, | ||
14 | + mounted () { | ||
15 | + setTimeout(() => { | ||
16 | + this.data = [{ | ||
9 | value: 'beijing', | 17 | value: 'beijing', |
10 | label: '北京', | 18 | label: '北京', |
11 | children: [ | 19 | children: [ |
@@ -51,14 +59,8 @@ | @@ -51,14 +59,8 @@ | ||
51 | ] | 59 | ] |
52 | } | 60 | } |
53 | ], | 61 | ], |
54 | - }], | ||
55 | - value3: [] | ||
56 | - } | ||
57 | - }, | ||
58 | - methods: { | ||
59 | - hc (a,b) { | ||
60 | - console.log(a,b) | ||
61 | - } | 62 | + }]; |
63 | + }, 100) | ||
62 | } | 64 | } |
63 | } | 65 | } |
64 | </script> | 66 | </script> |
src/components/cascader/cascader.vue
@@ -258,8 +258,9 @@ | @@ -258,8 +258,9 @@ | ||
258 | updateResult (result) { | 258 | updateResult (result) { |
259 | this.tmpSelected = result; | 259 | this.tmpSelected = result; |
260 | }, | 260 | }, |
261 | - updateSelected (init = false) { | ||
262 | - if (!this.changeOnSelect || init) { | 261 | + updateSelected (init = false, changeOnSelectDataChange = false) { |
262 | + // #2793 changeOnSelectDataChange used for changeOnSelect when data changed and set value | ||
263 | + if (!this.changeOnSelect || init || changeOnSelectDataChange) { | ||
263 | this.broadcast('Caspanel', 'on-find-selected', { | 264 | this.broadcast('Caspanel', 'on-find-selected', { |
264 | value: this.currentValue | 265 | value: this.currentValue |
265 | }); | 266 | }); |
@@ -386,7 +387,7 @@ | @@ -386,7 +387,7 @@ | ||
386 | if (validDataStr !== this.validDataStr) { | 387 | if (validDataStr !== this.validDataStr) { |
387 | this.validDataStr = validDataStr; | 388 | this.validDataStr = validDataStr; |
388 | if (!this.isLoadedChildren) { | 389 | if (!this.isLoadedChildren) { |
389 | - this.$nextTick(() => this.updateSelected()); | 390 | + this.$nextTick(() => this.updateSelected(false, this.changeOnSelect)); |
390 | } | 391 | } |
391 | this.isLoadedChildren = false; | 392 | this.isLoadedChildren = false; |
392 | } | 393 | } |