TuBadge 徽标
数字 / 文本胶囊或红点,数字超过 max 自动显示 max+。
徽标:数字 / 文本胶囊或红点,挂在任意内容旁。数字超过 max 自动显示为 max+(双端由同一表达式求值)。无交互事件。
属性
| 名称 | 类型 | 说明 |
|---|---|---|
content | number | string | 徽标内容:数字或文本。 |
max | number | 数字上限:content 为数字且超过 max 时显示 max+。 |
dot | boolean | 纯圆点模式(忽略 content 文本)。 |
color | string | 颜色,默认 var(--tu-danger)。 |
textColor | string | 文本颜色,默认 #ffffff。 |
8
当前徽标显示 8(实际计数 8)—— content 超过 max 时自动显示 max+。
实例
ts
// 数字徽标:超过 max 显示 max+
createComponent({
component: TuBadge,
props: { content: this.state.unread, max: 99 },
children: [{ tag: 'span', children: ['消息'] }],
});
// 纯圆点徽标
createComponent({
component: TuBadge,
props: { dot: true },
children: [{ tag: 'span', children: ['设置'] }],
});