[Improvement] Rate: add change event (#1102)

This commit is contained in:
neverland 2018-05-19 09:23:06 +08:00 committed by GitHub
parent 9bafa62ba4
commit 86a2569614
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -43,7 +43,7 @@ export default {
<van-rate v-model="value" disabled /> <van-rate v-model="value" disabled />
``` ```
### Rate API ### API
| Attribute | Description | Type | Default | | Attribute | Description | Type | Default |
|-----------|-----------|-----------|-------------| |-----------|-----------|-----------|-------------|
@ -54,3 +54,9 @@ export default {
| void-color | Void color | `String` | `#c7c7c7` | | void-color | Void color | `String` | `#c7c7c7` |
| disabled-color | Disabled color | `String` | `#bdbdbd` | | disabled-color | Disabled color | `String` | `#bdbdbd` |
| disabled | Whether to disable rate | `Boolean` | `false` | | disabled | Whether to disable rate | `Boolean` | `false` |
### Event
| Event | Description | Parameters |
|-----------|-----------|-----------|
| change | Triggered when rate changed | current rate |

View File

@ -66,6 +66,7 @@ export default create({
onSelect(index) { onSelect(index) {
if (!this.disabled) { if (!this.disabled) {
this.$emit('input', index + 1); this.$emit('input', index + 1);
this.$emit('change', index + 1);
} }
} }
} }

View File

@ -43,7 +43,7 @@ export default {
<van-rate v-model="value" disabled /> <van-rate v-model="value" disabled />
``` ```
### Rate API ### API
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
|-----------|-----------|-----------|-------------| |-----------|-----------|-----------|-------------|
@ -54,3 +54,9 @@ export default {
| void-color | 未选中时的颜色 | `String` | `#c7c7c7` | | void-color | 未选中时的颜色 | `String` | `#c7c7c7` |
| disabled-color | 不可选时的颜色 | `String` | `#bdbdbd` | | disabled-color | 不可选时的颜色 | `String` | `#bdbdbd` |
| disabled | 是否禁用评分 | `Boolean` | `false` | | disabled | 是否禁用评分 | `Boolean` | `false` |
### Event
| 事件名称 | 说明 | 回调参数 |
|-----------|-----------|-----------|
| change | 当前分值变化时触发的事件 | 当前分值 |