7fa943eb
梁灏
init
|
1
|
<template>
|
456daf34
梁灏
support Tag
|
2
3
4
5
6
|
<transition name="fade">
<div :class="classes">
<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>
</div>
</transition>
|
7fa943eb
梁灏
init
|
7
8
9
10
11
12
13
14
|
</template>
<script>
import Icon from '../icon';
import { oneOf } from '../../utils/assist';
const prefixCls = 'ivu-tag';
export default {
|
34ee7b4a
梁灏
support Tree & ad...
|
15
|
name: 'Tag',
|
7fa943eb
梁灏
init
|
16
17
18
19
20
21
22
23
24
25
|
components: { Icon },
props: {
closable: {
type: Boolean,
default: false
},
color: {
validator (value) {
return oneOf(value, ['blue', 'green', 'red', 'yellow']);
}
|
382c000c
梁灏
Tag add type prop...
|
26
27
28
29
30
|
},
type: {
validator (value) {
return oneOf(value, ['border', 'dot']);
}
|
7fa943eb
梁灏
init
|
31
32
|
}
},
|
7fa943eb
梁灏
init
|
33
34
35
36
37
|
computed: {
classes () {
return [
`${prefixCls}`,
{
|
382c000c
梁灏
Tag add type prop...
|
38
39
40
|
[`${prefixCls}-${this.color}`]: !!this.color,
[`${prefixCls}-${this.type}`]: !!this.type,
[`${prefixCls}-closable`]: this.closable
|
7fa943eb
梁灏
init
|
41
|
}
|
b0893113
jingsam
add eslint
|
42
|
];
|
7fa943eb
梁灏
init
|
43
44
45
|
},
textClasses () {
return `${prefixCls}-text`;
|
382c000c
梁灏
Tag add type prop...
|
46
47
48
49
50
51
|
},
dotClasses () {
return `${prefixCls}-dot-inner`;
},
showDot () {
return !!this.type && this.type === 'dot';
|
7fa943eb
梁灏
init
|
52
53
54
55
|
}
},
methods: {
close (e) {
|
7fa943eb
梁灏
init
|
56
57
58
|
this.$emit('on-close', e);
}
}
|
b0893113
jingsam
add eslint
|
59
60
|
};
</script>
|