mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
1.4 KiB
1.4 KiB
Badge 徽章
使用指南
在 index.json 中引入组件
"usingComponents": {
"van-badge": "path/to/vant-weapp/dist/badge/index",
"van-badge-group": "path/to/vant-weapp/dist/badge-group/index"
}
代码演示
基础用法
通过在van-badge-group
上设置active
属性来控制选中的badge
<van-badge-group :active="active" bind:change="onChange">
<van-badge title="标签名称" />
<van-badge title="标签名称" info="8" />
<van-badge title="标签名称" info="99" />
<van-badge title="标签名称" info="199" />
</van-badge-group>
export default {
data: {
active: 0
},
methods: {
onChange(event) {
wx.showToast({
icon: 'none',
title: `切换至第${event.detail}项`
});
}
}
};
BadgeGroup API
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
active | 选中badge 的索引 |
`String | Number` |
Badge API
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
title | 内容 | String |
'' |
info | 提示消息 | `String | Number` |
BadgeGroup 外部样式类
类名 | 说明 |
---|---|
custom-class | 根节点样式类 |
Badge 外部样式类
类名 | 说明 |
---|---|
custom-class | 根节点样式类 |