Skip to content

Badge 徽標 ​

圖示右上角的角標,用於通知數、狀態點或自訂文案。

基礎用法 ​

vue
<template>
  <lh-badge :value="8">
    <lh-button size="small">消息</lh-button>
  </lh-badge>
  <lh-badge :value="8" type="primary">
    <lh-button size="small">主要</lh-button>
  </lh-badge>
</template>

數值處理 ​

vue
<template>
  <lh-badge :value="200" :max="99">
    <lh-button size="small">超出 max 显示 99+</lh-button>
  </lh-badge>
  <lh-badge :value="0" show-zero>
    <lh-button size="small">显示 0</lh-button>
  </lh-badge>
  <lh-badge :value="0">
    <lh-button size="small">隐藏 0</lh-button>
  </lh-badge>
  <lh-badge content="新">
    <lh-button size="small">自定义文案</lh-button>
  </lh-badge>
</template>

小紅點 ​

vue
<template>
  <lh-badge is-dot>
    <lh-button size="small">有新消息</lh-button>
  </lh-badge>
</template>

偏移與尺寸 ​

vue
<template>
  <lh-badge :value="8" :offset="[6, 4]">
    <lh-button size="small">偏移</lh-button>
  </lh-badge>
  <lh-badge :value="8" size="small">
    <lh-button size="small">小号</lh-button>
  </lh-badge>
</template>

Props ​

屬性說明類型預設值
type類型'primary' | 'success' | 'warning' | 'danger' | 'info' | 'default''danger'
value顯示的數值string | number—
size尺寸'small' | 'medium' | 'large''medium'
max最大值,超出顯示 ${max}+number99
isDot是否為小紅點(不顯示數值)booleanfalse
hidden是否隱藏booleanfalse
offset相對預設位置的偏移 [x, y],取負 margin 實現[number, number]—
showZerovalue 為 0 時是否顯示booleanfalse
content自訂文案(優先於 value)string—
customClass自訂類別名string—
sx快速版面配置屬性LhSxProps—

Slots ​

插槽說明
default徽標依附的內容

與 Vue3 版的差異

進出動畫不依賴 Vue 內建 <transition>(小程序的過渡結束事件不可靠),改 class 切換 + 計時器對齊 0.15s 動畫時長,視覺表現與 plus 一致。