diff --git a/docs/examples-docs/badge.md b/docs/examples-docs/badge.md index b0f27058c..6da67fc0c 100644 --- a/docs/examples-docs/badge.md +++ b/docs/examples-docs/badge.md @@ -1,29 +1,36 @@ ## Badge 徽章 @@ -39,48 +46,44 @@ Vue.component(Badge.name, Badge); #### 基础用法 -默认情况下激活第一个`badge`。 +通过在`van-badge-group`上设置`active-key`属性来控制选中的`badge` :::demo 基础用法 ```html -
- - - - - - -
+ + + + + + +``` + +``` javascript +export default { + data() { + return { + activeKey: 0 + }; + }, + methods: { + onClick(key) { + this.activeKey = key; + } + } +}; ``` ::: -#### 选中某个badge -如果想默认选中某个`badge`,你可以在`van-badge-group`上设置`activeKey`属性,属性值为对应的`badge`索引。 +### BadgeGroup API -:::demo 选中某个badge -```html -
- - - - - - -
-``` -::: - -### z-badge-group API - -| 参数 | 说明 | 类型 | 默认值 | 必须 | +| 参数 | 说明 | 类型 | 默认值 | 可选值 | |-----------|-----------|-----------|-------------|-------------| -| active-key | 激活的`badge`的索引 | `string` | `0`但必须子badge里的mark是有`0`位索引 | | +| active-key | 选中`badge`的索引 | `String | Number` | `0` | - | - -### z-badge API -| 参数 | 说明 | 类型 | 默认值 | 必须 | +### Badge API +| 参数 | 说明 | 类型 | 默认值 | 可选值 | |-----------|-----------|-----------|-------------|-------------| -| title | badge的文案标题 | `string` | `''` | `required` | -| info | 当前badge的提示消息 | `string` | `''` | | -| url | 跳转链接 | `string` | 链接直接跳转或者hash | | +| title | 内容 | `String` | `''` | - | +| info | 提示消息 | `String` | `''` | - | +| url | 跳转链接 | `String` | - | - | diff --git a/packages/badge/index.vue b/packages/badge/index.vue index 7808d6755..9ed36df14 100644 --- a/packages/badge/index.vue +++ b/packages/badge/index.vue @@ -1,12 +1,8 @@ @@ -40,12 +36,8 @@ export default { }, methods: { - handleClick(e) { - this.$emit('click', e, { - title: this.title, - url: this.url, - info: this.info - }); + onClick() { + this.$emit('click', this.$parent.badges.indexOf(this)); } } };