TuBadge 徽标

数字 / 文本胶囊或红点,数字超过 max 自动显示 max+。

徽标:数字 / 文本胶囊或红点,挂在任意内容旁。数字超过 max 自动显示为 max+(双端由同一表达式求值)。无交互事件。

属性
名称类型说明
contentnumber | string徽标内容:数字或文本。
maxnumber数字上限:content 为数字且超过 max 时显示 max+。
dotboolean纯圆点模式(忽略 content 文本)。
colorstring颜色,默认 var(--tu-danger)。
textColorstring文本颜色,默认 #ffffff。
8
+1
清零

当前徽标显示 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: ['设置'] }],
});