Commit 687c4562f12e3e6adc704b6163e9eab4c8623a21

Authored by 梁灏
1 parent 5d5f8dc8

fixed #810

examples/routers/cascader.vue
1 1 <template>
2   - <div>
3   - <Cascader :data="data2" v-model="v1" disabled clearable></Cascader>
4   - <Cascader :data="data2" clearable></Cascader>
  2 + <div style="width: 300px;margin: 100px;">
  3 + <Cascader :data="data2" v-model="v1" change-on-select></Cascader>
5 4 </div>
6 5 </template>
7 6 <script>
8 7 export default {
9 8 data () {
10 9 return {
11   - v1: ['zhejiang', 'hangzhou', 'xihu'],
  10 + v1: ['zhejiang'],
12 11 data2: [{
13 12 value: 'zhejiang',
14 13 label: '浙江',
... ... @@ -23,7 +22,6 @@
23 22 }, {
24 23 value: 'jiangsu',
25 24 label: '江苏',
26   - disabled: true,
27 25 children: [{
28 26 value: 'nanjing',
29 27 label: '南京',
... ...
src/components/cascader/cascader.vue
... ... @@ -172,8 +172,7 @@
172 172 }
173 173 }
174 174 },
175   - mounted () {
176   - this.updateSelected(true);
  175 + created () {
177 176 this.$on('on-result-change', (params) => {
178 177 // lastValue: is click the final val
179 178 // fromInit: is this emit from update value
... ... @@ -201,6 +200,9 @@
201 200 }
202 201 });
203 202 },
  203 + mounted () {
  204 + this.updateSelected(true);
  205 + },
204 206 watch: {
205 207 visible (val) {
206 208 if (val) {
... ...
src/components/cascader/caspanel.vue
... ... @@ -60,10 +60,8 @@
60 60 const backItem = this.getBaseItem(item);
61 61 this.tmpItem = backItem;
62 62 this.emitUpdate([backItem]);
63   -
64 63 if (item.children && item.children.length){
65 64 this.sublist = item.children;
66   -// this.$dispatch('on-result-change', false, this.changeOnSelect, fromInit);
67 65 this.dispatch('Cascader', 'on-result-change', {
68 66 lastValue: false,
69 67 changeOnSelect: this.changeOnSelect,
... ... @@ -71,7 +69,6 @@
71 69 });
72 70 } else {
73 71 this.sublist = [];
74   -// this.$dispatch('on-result-change', true, this.changeOnSelect, fromInit);
75 72 this.dispatch('Cascader', 'on-result-change', {
76 73 lastValue: true,
77 74 changeOnSelect: this.changeOnSelect,
... ...