This commit is contained in:
梁灏 2017-05-04 10:33:50 +08:00
parent 5d5f8dc8c6
commit 687c4562f1
3 changed files with 7 additions and 10 deletions

View file

@ -1,14 +1,13 @@
<template> <template>
<div> <div style="width: 300px;margin: 100px;">
<Cascader :data="data2" v-model="v1" disabled clearable></Cascader> <Cascader :data="data2" v-model="v1" change-on-select></Cascader>
<Cascader :data="data2" clearable></Cascader>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return { return {
v1: ['zhejiang', 'hangzhou', 'xihu'], v1: ['zhejiang'],
data2: [{ data2: [{
value: 'zhejiang', value: 'zhejiang',
label: '浙江', label: '浙江',
@ -23,7 +22,6 @@
}, { }, {
value: 'jiangsu', value: 'jiangsu',
label: '江苏', label: '江苏',
disabled: true,
children: [{ children: [{
value: 'nanjing', value: 'nanjing',
label: '南京', label: '南京',

View file

@ -172,8 +172,7 @@
} }
} }
}, },
mounted () { created () {
this.updateSelected(true);
this.$on('on-result-change', (params) => { this.$on('on-result-change', (params) => {
// lastValue: is click the final val // lastValue: is click the final val
// fromInit: is this emit from update value // fromInit: is this emit from update value
@ -201,6 +200,9 @@
} }
}); });
}, },
mounted () {
this.updateSelected(true);
},
watch: { watch: {
visible (val) { visible (val) {
if (val) { if (val) {

View file

@ -60,10 +60,8 @@
const backItem = this.getBaseItem(item); const backItem = this.getBaseItem(item);
this.tmpItem = backItem; this.tmpItem = backItem;
this.emitUpdate([backItem]); this.emitUpdate([backItem]);
if (item.children && item.children.length){ if (item.children && item.children.length){
this.sublist = item.children; this.sublist = item.children;
// this.$dispatch('on-result-change', false, this.changeOnSelect, fromInit);
this.dispatch('Cascader', 'on-result-change', { this.dispatch('Cascader', 'on-result-change', {
lastValue: false, lastValue: false,
changeOnSelect: this.changeOnSelect, changeOnSelect: this.changeOnSelect,
@ -71,7 +69,6 @@
}); });
} else { } else {
this.sublist = []; this.sublist = [];
// this.$dispatch('on-result-change', true, this.changeOnSelect, fromInit);
this.dispatch('Cascader', 'on-result-change', { this.dispatch('Cascader', 'on-result-change', {
lastValue: true, lastValue: true,
changeOnSelect: this.changeOnSelect, changeOnSelect: this.changeOnSelect,