Badge 徽标
图标右上角的圆形徽标数字。
何时使用
一般出现在通知图标或头像的右上角,用于显示需要处理的消息条数,通过醒目视觉形式吸引用户处理。
示例
基本使用:
<template>
<f-space :size="30">
默认颜色
<f-badge count="2">
<f-avatar shape="square" />
</f-badge>
<f-badge count="99">
<f-avatar shape="square" />
</f-badge>
<f-badge count="100">
<f-avatar shape="square" />
</f-badge>
<f-badge count="Hot">
<f-avatar shape="square" />
</f-badge>
<f-badge dot>
<f-avatar shape="square" />
</f-badge>
</f-space>
<br />
<br />
<f-space :size="30">
自定义颜色
<f-badge :number-style="numberStyle" count="2">
<f-avatar shape="square" />
</f-badge>
<f-badge :number-style="numberStyle" count="99">
<f-avatar shape="square" />
</f-badge>
<f-badge :number-style="numberStyle" count="100">
<f-avatar shape="square" />
</f-badge>
<f-badge :number-style="numberStyle" count="Hot">
<f-avatar shape="square" />
</f-badge>
<f-badge :number-style="numberStyle" dot>
<f-avatar shape="square" />
</f-badge>
</f-space>
<br />
<br />
<f-space>
自定义图标
<f-badge>
<template #count>
<ClockCircleFilled style="color: #f04141; font-size: 16px; box-shadow: 0 0 0 1px #fff" />
</template>
<f-avatar shape="square" />
</f-badge>
</f-space>
</template>
<script lang="ts" setup>
import { ClockCircleFilled } from '@ant-design/icons-vue'
const numberStyle = {
backgroundColor: '#DDDDDD',
color: '#666666',
boxShadow: '0 0 0 2px #fff',
}
</script>
API
<f-badge :count="5">
<a href="#" class="head-example" />
</f-badge>
Badge
参数 | 说明 | 类型 | 默认值 | 版本 |
---|
color | 自定义小圆点的颜色 | string | - | 1.5.0 |
count | 展示的数字,大于 overflowCount 时显示为 ${overflowCount}+ ,为 0 时隐藏 | number | string | slot | | |
dot | 不展示数字,只有一个小红点 | boolean | false | |
numberStyle | 设置状态点的样式 | object | '' | |
offset | 设置状态点的位置偏移,格式为 [x, y] | [number|string, number|string] | - | |
overflowCount | 展示封顶的数字值 | number | 99 | |
showZero | 当数值为 0 时,是否展示 Badge | boolean | false | |
status | 设置 Badge 为状态点 | Enum{ 'success', 'processing, 'default', 'error', 'warning' } | '' | |
text | 在设置了 status 的前提下有效,设置状态点的文本 | string | '' | |
title | 设置鼠标放在状态点上时显示的文字 | string | count | |
Badge.Ribbon (2.0.1+)
参数 | 说明 | 类型 | 默认值 | 版本 |
---|
color | 自定义缎带的颜色 | string | - | |
placement | 缎带的位置,start 和 end 随文字方向(RTL 或 LTR)变动 | start | end | end | |
text | 缎带中填入的内容 | string | VNode | slot | - | |