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

View file

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

View file

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