diff --git a/src/checkbox/Checker.tsx b/src/checkbox/Checker.tsx index a8ee4c821..3cab14fab 100644 --- a/src/checkbox/Checker.tsx +++ b/src/checkbox/Checker.tsx @@ -90,7 +90,7 @@ export default defineComponent({ style={{ fontSize: addUnit(iconSize) }} > {slots.icon ? ( - slots.icon({ checked }) + slots.icon({ checked, disabled: disabled.value }) ) : ( )} diff --git a/src/checkbox/README.md b/src/checkbox/README.md index 6b8b63b40..50e418969 100644 --- a/src/checkbox/README.md +++ b/src/checkbox/README.md @@ -283,10 +283,10 @@ export default { ### Checkbox Slots -| Name | Description | SlotProps | -| ------- | ------------ | ------------------ | -| default | Custom label | - | -| icon | Custom icon | _checked: boolean_ | +| Name | Description | SlotProps | +| ------- | ------------ | ----------------------------------------- | +| default | Custom label | - | +| icon | Custom icon | _{ checked: boolean, disabled: boolean }_ | ### CheckboxGroup Methods diff --git a/src/checkbox/README.zh-CN.md b/src/checkbox/README.zh-CN.md index 1831d64c0..905f92649 100644 --- a/src/checkbox/README.zh-CN.md +++ b/src/checkbox/README.zh-CN.md @@ -301,10 +301,10 @@ export default { ### Checkbox Slots -| 名称 | 说明 | 参数 | -| ------- | ---------- | ------------------ | -| default | 自定义文本 | - | -| icon | 自定义图标 | _checked: boolean_ | +| 名称 | 说明 | 参数 | +| ------- | ---------- | ----------------------------------------- | +| default | 自定义文本 | - | +| icon | 自定义图标 | _{ checked: boolean, disabled: boolean }_ | ### CheckboxGroup 方法 diff --git a/src/checkbox/test/__snapshots__/index.spec.ts.snap b/src/checkbox/test/__snapshots__/index.spec.ts.snap index 3d6979609..ebf42fdae 100644 --- a/src/checkbox/test/__snapshots__/index.spec.ts.snap +++ b/src/checkbox/test/__snapshots__/index.spec.ts.snap @@ -15,3 +15,9 @@ exports[`should adjust label position when using label-position prop 1`] = ` `; + +exports[`should render icon slot correctly 1`] = ` +
+ checked: false, disabled: false +
+`; diff --git a/src/checkbox/test/index.spec.ts b/src/checkbox/test/index.spec.ts index c486f30fa..a07c274e6 100644 --- a/src/checkbox/test/index.spec.ts +++ b/src/checkbox/test/index.spec.ts @@ -105,3 +105,14 @@ test('should emit click event when checkbox icon is clicked', async () => { icon.trigger('click'); expect(onClick).toHaveBeenCalledTimes(2); }); + +test('should render icon slot correctly', async () => { + const wrapper = mount(Checkbox, { + slots: { + icon: ({ checked, disabled }) => + `checked: ${checked}, disabled: ${disabled}`, + }, + }); + + expect(wrapper.find('.van-checkbox__icon').html()).toMatchSnapshot(); +}); diff --git a/src/radio/README.md b/src/radio/README.md index 00f6fc7e4..e9c609aa4 100644 --- a/src/radio/README.md +++ b/src/radio/README.md @@ -194,10 +194,10 @@ export default { ### Radio Slots -| Name | Description | SlotProps | -| ------- | ------------ | ------------------ | -| default | Custom label | - | -| icon | Custom icon | _checked: boolean_ | +| Name | Description | SlotProps | +| ------- | ------------ | ----------------------------------------- | +| default | Custom label | - | +| icon | Custom icon | _{ checked: boolean, disabled: boolean }_ | ### Less Variables diff --git a/src/radio/README.zh-CN.md b/src/radio/README.zh-CN.md index 40cc74fcf..02b7adc40 100644 --- a/src/radio/README.zh-CN.md +++ b/src/radio/README.zh-CN.md @@ -208,10 +208,10 @@ export default { ### Radio Slots -| 名称 | 说明 | 参数 | -| ------- | ---------- | ------------------ | -| default | 自定义文本 | - | -| icon | 自定义图标 | _checked: boolean_ | +| 名称 | 说明 | 参数 | +| ------- | ---------- | ----------------------------------------- | +| default | 自定义文本 | - | +| icon | 自定义图标 | _{ checked: boolean, disabled: boolean }_ | ### 样式变量