-
Notifications
You must be signed in to change notification settings - Fork 10
/
Tag.vue
102 lines (102 loc) · 1.83 KB
/
Tag.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<template>
<span :class="['wt-tag', type, stroke ? 'stroke' : '', flag ? 'flag' : '']" :style="styles">{{title}}</span>
</template>
<script>
import { computed } from "vue";
export default {
props: {
title: {
type: String,
default: () => {
return "tag";
}
},
type: {
type: String,
default: () => {
return "default";
}
},
color: {
type: String,
default: () => {
return "";
}
},
stroke: {
type: Boolean,
default: () => {
return false;
}
}
},
setup(props) {
const styles = computed(() => {
if (props.color && !props.stroke) {
return {
backgroundColor: props.color
};
} else if (props.stroke && props.color) {
return {
color: props.color,
border: "1px solid " + props.color
};
}
});
// 暴露给模板
return {
styles
};
}
};
</script>
<style lang="less" scoped>
.wt-tag {
display: inline-flex;
-webkit-box-align: center;
align-items: center;
padding: 0.2em 0.5em;
color: #fff;
font-size: 10px;
line-height: normal;
border-radius: 0.2em;
&.default {
background-color: #969799;
}
&.info {
background-color: #1bb5f1;
}
&.danger {
background-color: #ef4f4f;
}
&.success {
background-color: #37bf4f;
}
&.warning {
background-color: #fadb14;
}
&.stroke {
background: transparent;
&.default {
border: 1px solid #969799;
color: #969799;
}
&.info {
border: 1px solid #1bb5f1;
color: #1bb5f1;
}
&.danger {
border: 1px solid #ef4f4f;
color: #ef4f4f;
}
&.success {
border: 1px solid #37bf4f;
color: #37bf4f;
}
&.warning {
border: 1px solid #fadb14;
color: #fadb14;
}
}
}
</style>