This commit is contained in:
梁灏 2017-08-08 17:19:03 +08:00
parent 6da6fffa1d
commit daa9827c92
3 changed files with 114 additions and 106 deletions

View file

@ -1,19 +1,13 @@
<template>
<div style="width: 400px;">
<Row>
<i-col span="12">
<Cascader transfer v-model="value3" :data="data" filterable></Cascader>
</i-col>
<i-col span="12">
<Cascader v-model="value3" :data="data" filterable></Cascader>
</i-col>
</Row>
<div style="margin: 100px;width: 200px;">
<Cascader :data="data" v-model="value1" change-on-select></Cascader>
</div>
</template>
<script>
export default {
data () {
return {
value1: [],
data: [{
value: 'beijing',
label: '北京',
@ -60,8 +54,7 @@
]
}
],
}],
value3: []
}]
}
}
}

View file

@ -15,7 +15,7 @@
<script>
import Casitem from './casitem.vue';
import Emitter from '../../mixins/emitter';
import { findComponentUpward } from '../../utils/assist';
import { findComponentUpward, findComponentDownward } from '../../utils/assist';
let key = 1;
@ -84,6 +84,14 @@
changeOnSelect: this.changeOnSelect,
fromInit: fromInit
});
// #1553
if (this.changeOnSelect) {
const Caspanel = findComponentDownward(this, 'Caspanel');
if (Caspanel) {
Caspanel.$emit('on-clear', true);
}
}
} else {
this.sublist = [];
this.dispatch('Cascader', 'on-result-change', {
@ -135,9 +143,16 @@
}
}
});
this.$on('on-clear', () => {
// deep for #1553
this.$on('on-clear', (deep = false) => {
this.sublist = [];
this.tmpItem = {};
if (deep) {
const Caspanel = findComponentDownward(this, 'Caspanel');
if (Caspanel) {
Caspanel.$emit('on-clear', true);
}
}
});
}
};