Merge pull request #258 from YikaJ/master

Select组件/Tag组件
This commit is contained in:
Aresn 2017-02-15 10:29:04 +08:00 committed by GitHub
commit 8f48491aa6
4 changed files with 77 additions and 44 deletions

View file

@ -478,22 +478,25 @@
setQuery (query) {
if (!this.filterable) return;
this.query = query;
},
modelToQuery() {
if (!this.multiple && this.filterable && this.model) {
this.findChild((child) => {
if (this.model === child.value) {
if (child.label) {
this.query = child.label;
} else if (child.searchLabel) {
this.query = child.searchLabel;
} else {
this.query = child.value;
}
}
});
}
}
},
compiled () {
if (!this.multiple && this.filterable && this.model) {
this.findChild((child) => {
if (this.model === child.value) {
if (child.label) {
this.query = child.label;
} else if (child.searchLabel) {
this.query = child.searchLabel;
} else {
this.query = child.value;
}
}
});
}
this.modelToQuery();
this.updateOptions(true);
document.addEventListener('keydown', this.handleKeydown);
@ -501,6 +504,7 @@
// watch slot changed
if (MutationObserver) {
this.observer = new MutationObserver(() => {
this.modelToQuery();
this.slotChange();
this.updateOptions(true, true);
});
@ -521,6 +525,7 @@
},
watch: {
model () {
this.modelToQuery();
if (this.multiple) {
if (this.slotChangeDuration) {
this.slotChangeDuration = false;

View file

@ -1,6 +1,6 @@
<template>
<div :class="classes" transition="fade">
<span :class="dotClasses" v-if="showDot"></span><span :class="textClasses"><slot></slot></span><Icon v-if="closable" type="ios-close-empty" @click="close"></Icon>
<span :class="dotClasses" v-if="showDot"></span><span :class="textClasses"><slot></slot></span><Icon v-if="closable" type="ios-close-empty" @click.stop="close"></Icon>
</div>
</template>
<script>