generated from thzxcx/vue3
108 lines
1.9 KiB
Vue
108 lines
1.9 KiB
Vue
<!--
|
|
* @Author: peerless_hero peerless_hero@outlook.com
|
|
* @Date: 2023-07-11 02:12:08
|
|
* @LastEditors: Hefeng 1057605508@qq.com
|
|
* @LastEditTime: 2024-01-16 12:59:41
|
|
* @FilePath: \uni\packages\tag\index.vue
|
|
* @Description:
|
|
*
|
|
-->
|
|
<template>
|
|
<text
|
|
class="th-tag"
|
|
:class="className"
|
|
py-6rpx
|
|
px-2rpx
|
|
text-center
|
|
min-w-128rpx
|
|
text-24rpx
|
|
h-48rpx
|
|
font-500
|
|
border-2rpx
|
|
border-solid
|
|
>
|
|
{{ text }}
|
|
</text>
|
|
</template>
|
|
|
|
<script lang="ts" setup name="Tag">
|
|
import { computed } from 'vue'
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
radius?: boolean
|
|
/** 类型 */
|
|
type?: 'default' | 'primary' | 'danger' | 'warning' | 'success' | 'info'
|
|
/** 显示文本 */
|
|
text?: string
|
|
/** 纯文字,无背景色 */
|
|
plain?: boolean
|
|
}>(),
|
|
{
|
|
type: 'default',
|
|
|
|
},
|
|
)
|
|
|
|
const className = computed(() => {
|
|
const bg = props.plain ? '' : ' bgc'
|
|
const rd = props.radius ? ' rd-full' : ' rd-8rpx'
|
|
switch (props.type) {
|
|
case 'danger':
|
|
return `th-tag-danger${bg} ${rd}`
|
|
case 'primary':
|
|
return `th-tag-primary${bg} ${rd}`
|
|
case 'warning':
|
|
return `th-tag-warning${bg} ${rd}`
|
|
case 'success':
|
|
return `th-tag-success${bg} ${rd}`
|
|
default:
|
|
return `th-tag-default${bg} ${rd}`
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.th-tag {
|
|
|
|
&.th-tag-default {
|
|
border-color: #cccccc;
|
|
color: #393939;
|
|
&.bgc {
|
|
background-color: #f9f9f9;
|
|
}
|
|
}
|
|
|
|
&.th-tag-danger {
|
|
border-color: #fbc7c7;
|
|
color: #e43d33;
|
|
&.bgc{
|
|
background-color: #fef0f0;
|
|
}
|
|
}
|
|
|
|
&.th-tag-warning {
|
|
border-color: #f6ddb8;
|
|
color: #f3a73f;
|
|
&.bgc{
|
|
background-color: #fff6e8;
|
|
}
|
|
}
|
|
|
|
&.th-tag-success {
|
|
border-color: #c8eab7;
|
|
color: #18bc37;
|
|
&.bgc {
|
|
background-color: #f0f9eb;
|
|
}
|
|
}
|
|
&.th-tag-primary {
|
|
border-color: #bcddff;
|
|
color: #2979ff;
|
|
&.bgc{
|
|
background-color: #f2f7ff;
|
|
}
|
|
}
|
|
}
|
|
</style>
|