Commit 687c4562f12e3e6adc704b6163e9eab4c8623a21

Authored by 梁灏
1 parent 5d5f8dc8

fixed #810

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