mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[bugfix] Checkbox: click event untriggered when click icon (#2990)
This commit is contained in:
parent
ad25616b05
commit
7b0a3319ba
@ -159,6 +159,7 @@ export default {
|
|||||||
| Event | Description | Parameters |
|
| Event | Description | Parameters |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
| change | Triggered when value changed | current value |
|
| change | Triggered when value changed | current value |
|
||||||
|
| click | Triggered when click checkbox | event: Event |
|
||||||
|
|
||||||
### CheckboxGroup Event
|
### CheckboxGroup Event
|
||||||
|
|
||||||
|
@ -70,3 +70,19 @@ test('checkbox group', () => {
|
|||||||
icons.at(0).trigger('click');
|
icons.at(0).trigger('click');
|
||||||
expect(wrapper.vm.result).toEqual(['b']);
|
expect(wrapper.vm.result).toEqual(['b']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('click event', () => {
|
||||||
|
const onClick = jest.fn();
|
||||||
|
const wrapper = mount(Checkbox, {
|
||||||
|
listeners: {
|
||||||
|
click: onClick
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
wrapper.trigger('click');
|
||||||
|
expect(onClick.mock.calls.length).toEqual(1);
|
||||||
|
|
||||||
|
const icon = wrapper.find('.van-checkbox__icon');
|
||||||
|
icon.trigger('click');
|
||||||
|
expect(onClick.mock.calls.length).toEqual(2);
|
||||||
|
});
|
||||||
|
@ -144,8 +144,8 @@ export default {
|
|||||||
| name | 标识符 | `any` | - | - |
|
| name | 标识符 | `any` | - | - |
|
||||||
| shape | 形状,可选值为 `square` | `String` | `round` | - |
|
| shape | 形状,可选值为 `square` | `String` | `round` | - |
|
||||||
| v-model | 是否为选中状态 | `Boolean` | `false` | - |
|
| v-model | 是否为选中状态 | `Boolean` | `false` | - |
|
||||||
| disabled | 是否禁用单选框 | `Boolean` | `false` | - |
|
| disabled | 是否禁用复选框 | `Boolean` | `false` | - |
|
||||||
| label-disabled | 是否禁用单选框文本点击 | `Boolean` | `false` | - |
|
| label-disabled | 是否禁用复选框文本点击 | `Boolean` | `false` | - |
|
||||||
| label-position | 文本位置,可选值为 `left` | `String` | `right` | 1.1.11 |
|
| label-position | 文本位置,可选值为 `left` | `String` | `right` | 1.1.11 |
|
||||||
| checked-color | 选中状态颜色 | `String` | `#1989fa` | 1.4.3 |
|
| checked-color | 选中状态颜色 | `String` | `#1989fa` | 1.4.3 |
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ export default {
|
|||||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||||
|------|------|------|------|------|
|
|------|------|------|------|------|
|
||||||
| v-model | 所有选中项的标识符 | `Array` | - | - |
|
| v-model | 所有选中项的标识符 | `Array` | - | - |
|
||||||
| disabled | 是否禁用所有单选框 | `Boolean` | `false` | - |
|
| disabled | 是否禁用所有复选框 | `Boolean` | `false` | - |
|
||||||
| max | 设置最大可选数,0 为无限制 | `Number` | `0` | - |
|
| max | 设置最大可选数,0 为无限制 | `Number` | `0` | - |
|
||||||
|
|
||||||
### Checkbox Event
|
### Checkbox Event
|
||||||
@ -162,6 +162,7 @@ export default {
|
|||||||
| 事件名称 | 说明 | 回调参数 |
|
| 事件名称 | 说明 | 回调参数 |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
| change | 当绑定值变化时触发的事件 | 当前组件的值 |
|
| change | 当绑定值变化时触发的事件 | 当前组件的值 |
|
||||||
|
| click | 点击复选框时触发 | event: Event |
|
||||||
|
|
||||||
### CheckboxGroup Event
|
### CheckboxGroup Event
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ export const CheckboxMixin = (parent, bem) => ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
class={bem()}
|
class={bem()}
|
||||||
onClick={() => {
|
onClick={event => {
|
||||||
this.$emit('click');
|
this.$emit('click', event);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@ -68,6 +68,7 @@ export const CheckboxMixin = (parent, bem) => ({
|
|||||||
onClick={event => {
|
onClick={event => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.onClickIcon();
|
this.onClickIcon();
|
||||||
|
this.$emit('click', event);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{CheckIcon}
|
{CheckIcon}
|
||||||
|
@ -99,7 +99,6 @@ export default {
|
|||||||
| label-position | Can be set to `left` | `String` | `right` |
|
| label-position | Can be set to `left` | `String` | `right` |
|
||||||
| checked-color | Checked color | `String` | `#1989fa` | - |
|
| checked-color | Checked color | `String` | `#1989fa` | - |
|
||||||
|
|
||||||
|
|
||||||
### RadioGroup API
|
### RadioGroup API
|
||||||
|
|
||||||
| Attribute | Description | Type | Default |
|
| Attribute | Description | Type | Default |
|
||||||
@ -107,6 +106,12 @@ export default {
|
|||||||
| v-model | Name of checked radio | `any` | - |
|
| v-model | Name of checked radio | `any` | - |
|
||||||
| disabled | Diable all radios | `Boolean` | `false` |
|
| disabled | Diable all radios | `Boolean` | `false` |
|
||||||
|
|
||||||
|
### Radio Event
|
||||||
|
|
||||||
|
| Event | Description | Parameters |
|
||||||
|
|------|------|------|
|
||||||
|
| click | Triggered when click radio | event: Event |
|
||||||
|
|
||||||
### RadioGroup Event
|
### RadioGroup Event
|
||||||
|
|
||||||
| Event | Description | Parameters |
|
| Event | Description | Parameters |
|
||||||
|
@ -110,6 +110,12 @@ export default {
|
|||||||
| v-model | 当前选中项的标识符 | 任意类型 | - | - |
|
| v-model | 当前选中项的标识符 | 任意类型 | - | - |
|
||||||
| disabled | 是否禁用所有单选框 | `Boolean` | `false` | - |
|
| disabled | 是否禁用所有单选框 | `Boolean` | `false` | - |
|
||||||
|
|
||||||
|
### Radio Event
|
||||||
|
|
||||||
|
| 事件名称 | 说明 | 回调参数 |
|
||||||
|
|------|------|------|
|
||||||
|
| click | 点击单选框时触发 | event: Event |
|
||||||
|
|
||||||
### RadioGroup Event
|
### RadioGroup Event
|
||||||
|
|
||||||
| 事件名称 | 说明 | 回调参数 |
|
| 事件名称 | 说明 | 回调参数 |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user