[Improvement] optimize find parent mixin (#781)

This commit is contained in:
neverland
2018-03-26 21:20:00 +08:00
committed by GitHub
parent dadf733d71
commit 5497eef5ef
13 changed files with 82 additions and 105 deletions

View File

@@ -10,13 +10,9 @@ import create from '../utils/create';
export default create({
name: 'collapse',
model: {
prop: 'activeNames'
},
props: {
accordion: Boolean,
activeNames: [String, Number, Array]
value: [String, Number, Array]
},
data() {
@@ -27,11 +23,10 @@ export default create({
methods: {
switch(name, expanded) {
const { activeNames } = this;
if (!this.accordion) {
name = expanded
? activeNames.concat(name)
: activeNames.filter(activeName => activeName !== name);
? this.value.concat(name)
: this.value.filter(activeName => activeName !== name);
}
this.$emit('change', name);
this.$emit('input', name);