Commit 4c6d996226ae4e892de35808a6ca14fc37585f61
Committed by
GitHub
1 parent
62bf2b3c
Update tag.vue
Showing
1 changed file
with
12 additions
and
10 deletions
Show diff stats
src/components/tag/tag.vue
1 | <template> | 1 | <template> |
2 | <transition name="fade"> | 2 | <transition name="fade"> |
3 | <div :class="classes" @click.stop="check"> | 3 | <div :class="classes" @click.stop="check"> |
4 | - <span :class="dotClasses" v-if="showDot"></span><span :class="textClasses"><slot></slot></span> | ||
5 | - <Icon v-if="closable" type="ios-close-empty" @click.native.stop="close"></Icon> | 4 | + <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> |
6 | </div> | 5 | </div> |
7 | </transition> | 6 | </transition> |
8 | </template> | 7 | </template> |
@@ -71,17 +70,20 @@ | @@ -71,17 +70,20 @@ | ||
71 | }, | 70 | }, |
72 | methods: { | 71 | methods: { |
73 | close (event) { | 72 | close (event) { |
74 | - this._emitAction(event, 'on-close'); | ||
75 | - }, | ||
76 | - check (event) { | ||
77 | - this.isChecked = !this.isChecked; | ||
78 | - this._emitAction(event, 'on-check'); | 73 | + if (this.name === undefined) { |
74 | + this.$emit('on-close', event); | ||
75 | + } else { | ||
76 | + this.$emit('on-close', event, this.name); | ||
77 | + } | ||
79 | }, | 78 | }, |
80 | - _emitAction (event, action) { | 79 | + check () { |
80 | + if (!this.checkable) return; | ||
81 | + const checked = !this.isChecked; | ||
82 | + this.isChecked = checked; | ||
81 | if (this.name === undefined) { | 83 | if (this.name === undefined) { |
82 | - this.$emit(action, event); | 84 | + this.$emit('on-change', checked); |
83 | } else { | 85 | } else { |
84 | - this.$emit(action, event, this.name); | 86 | + this.$emit('on-change', checked, this.name); |
85 | } | 87 | } |
86 | } | 88 | } |
87 | } | 89 | } |