Skip to content

引入组件 ​

局部引入

ts
// parent.vue
const FBadge = defineAsyncComponent(() => import('@/components/formaui/f-badge/f-badge.vue'))

基础用法 ​

type属性:徽章类型(默认primary)

例:primary、success、warning、danger、white、whitePrimary、whiteSuccess、whiteWarning、whiteDanger、gray、black

html
<f-badge type="primary">primary</f-badge>
<f-badge type="success">success</f-badge>
<f-badge type="warning">warning</f-badge>
<f-badge type="danger">danger</f-badge>
<f-badge type="whitePrimary">whitePrimary</f-badge>
<f-badge type="whiteSuccess">whiteSuccess</f-badge>
<f-badge type="whiteWarning">whiteWarning</f-badge>
<f-badge type="whiteDanger">whiteDanger</f-badge>
<f-badge type="gray">gray</f-badge>
<f-badge type="black">black</f-badge>

isDot属性:是否为圆点

html
<f-badge is-dot is-absolute />

bgColor、textColor:自定义颜色

html
<f-badge bg-color="#000" text-color="#fff">自定义背景色</f-badge>

插槽 ​

名称说明
default显示内容

属性 ​

名称类型说明默认值
typestring样式类型,可传入[primary、success、warning、danger、white、whitePrimary、whiteSuccess、whiteWarning、whiteDanger、gray、black]primary
isDotboolean是否为圆点false
marginstring徽章外边距0
isAbsoluteboolean是否绝对定位false
topstring绝对定位时 top-8rpx
rightstring绝对定位时 right0
scaleRationumber缩放比例1
translateXstring水平偏移量0
bgColorstring自定义背景色-
textColorstring自定义文字颜色-

事件 ​

事件名说明回调参数
click点击事件-