Update tag.vue
This commit is contained in:
parent
62bf2b3ceb
commit
4c6d996226
1 changed files with 13 additions and 11 deletions
|
@ -1,8 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<transition name="fade">
|
<transition name="fade">
|
||||||
<div :class="classes" @click.stop="check">
|
<div :class="classes" @click.stop="check">
|
||||||
<span :class="dotClasses" v-if="showDot"></span><span :class="textClasses"><slot></slot></span>
|
<span :class="dotClasses" v-if="showDot"></span><span :class="textClasses"><slot></slot></span><Icon v-if="closable" type="ios-close-empty" @click.native.stop="close"></Icon>
|
||||||
<Icon v-if="closable" type="ios-close-empty" @click.native.stop="close"></Icon>
|
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
@ -71,17 +70,20 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
close (event) {
|
close (event) {
|
||||||
this._emitAction(event, 'on-close');
|
|
||||||
},
|
|
||||||
check (event) {
|
|
||||||
this.isChecked = !this.isChecked;
|
|
||||||
this._emitAction(event, 'on-check');
|
|
||||||
},
|
|
||||||
_emitAction (event, action) {
|
|
||||||
if (this.name === undefined) {
|
if (this.name === undefined) {
|
||||||
this.$emit(action, event);
|
this.$emit('on-close', event);
|
||||||
} else {
|
} else {
|
||||||
this.$emit(action, event, this.name);
|
this.$emit('on-close', event, this.name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
check () {
|
||||||
|
if (!this.checkable) return;
|
||||||
|
const checked = !this.isChecked;
|
||||||
|
this.isChecked = checked;
|
||||||
|
if (this.name === undefined) {
|
||||||
|
this.$emit('on-change', checked);
|
||||||
|
} else {
|
||||||
|
this.$emit('on-change', checked, this.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue