diff --git a/packages/vant/src/calendar/Calendar.tsx b/packages/vant/src/calendar/Calendar.tsx index 891522127..6f6dd0913 100644 --- a/packages/vant/src/calendar/Calendar.tsx +++ b/packages/vant/src/calendar/Calendar.tsx @@ -482,10 +482,9 @@ export default defineComponent({ } if (props.showConfirm) { - const text = buttonDisabled.value - ? props.confirmDisabledText - : props.confirmText; - + const slot = slots['confirm-text']; + const disabled = buttonDisabled.value; + const text = disabled ? props.confirmDisabledText : props.confirmText; return ( ); } diff --git a/packages/vant/src/calendar/README.md b/packages/vant/src/calendar/README.md index 7271be5a8..1f6d4650a 100644 --- a/packages/vant/src/calendar/README.md +++ b/packages/vant/src/calendar/README.md @@ -330,13 +330,14 @@ Following props are supported when the type is multiple ### Slots -| Name | Description | SlotProps | -| --------------------- | ------------------------- | ---------- | -| title | Custom title | - | -| subtitle `v3.1.3` | Custom subtitle | - | -| footer | Custom footer | - | -| top-info `v3.0.17` | Custom top info of day | _day: Day_ | -| bottom-info `v3.0.17` | Custom bottom info of day | _day: Day_ | +| Name | Description | SlotProps | +| --------------------- | ------------------------- | ----------------------- | +| title | Custom title | - | +| subtitle `v3.1.3` | Custom subtitle | - | +| footer | Custom footer | - | +| confirm-text `v3.2.6` | Custom confirm text | _{ disabled: boolean }_ | +| top-info `v3.0.17` | Custom top info of day | _day: Day_ | +| bottom-info `v3.0.17` | Custom bottom info of day | _day: Day_ | ### Methods diff --git a/packages/vant/src/calendar/README.zh-CN.md b/packages/vant/src/calendar/README.zh-CN.md index 3e58e4e68..48aaafe36 100644 --- a/packages/vant/src/calendar/README.zh-CN.md +++ b/packages/vant/src/calendar/README.zh-CN.md @@ -336,13 +336,14 @@ export default { ### Slots -| 名称 | 说明 | 参数 | -| --------------------- | ------------------------ | ---------- | -| title | 自定义标题 | - | -| subtitle `v3.1.3` | 自定义日历副标题 | - | -| footer | 自定义底部区域内容 | - | -| top-info `v3.0.17` | 自定义日期上方的提示信息 | _day: Day_ | -| bottom-info `v3.0.17` | 自定义日期下方的提示信息 | _day: Day_ | +| 名称 | 说明 | 参数 | +| --------------------- | ------------------------ | ----------------------- | +| title | 自定义标题 | - | +| subtitle `v3.1.3` | 自定义日历副标题 | - | +| footer | 自定义底部区域内容 | - | +| confirm-text `v3.2.6` | 自定义确认按钮的内容 | _{ disabled: boolean }_ | +| top-info `v3.0.17` | 自定义日期上方的提示信息 | _day: Day_ | +| bottom-info `v3.0.17` | 自定义日期下方的提示信息 | _day: Day_ | ### 方法 diff --git a/packages/vant/src/calendar/test/__snapshots__/index.spec.ts.snap b/packages/vant/src/calendar/test/__snapshots__/index.spec.ts.snap index b0be25fe9..6c7201065 100644 --- a/packages/vant/src/calendar/test/__snapshots__/index.spec.ts.snap +++ b/packages/vant/src/calendar/test/__snapshots__/index.spec.ts.snap @@ -900,6 +900,18 @@ exports[`row-height prop 1`] = ` `; +exports[`should render confirm-text slot correctly 1`] = ` + +`; + exports[`should render title、footer、subtitle slot correctly 1`] = `
diff --git a/packages/vant/src/calendar/test/index.spec.ts b/packages/vant/src/calendar/test/index.spec.ts index 6bbac63c0..2ae72fb22 100644 --- a/packages/vant/src/calendar/test/index.spec.ts +++ b/packages/vant/src/calendar/test/index.spec.ts @@ -569,3 +569,19 @@ test('should emit click-subtitle event when clicking the subtitle', async () => wrapper.find('.van-calendar__header-subtitle').trigger('click'); expect(wrapper.emitted('click-subtitle')).toBeTruthy(); }); + +test('should render confirm-text slot correctly', async () => { + const wrapper = mount(Calendar, { + props: { + poppable: false, + lazyRender: false, + }, + slots: { + 'confirm-text': ({ disabled }) => `Custom confirm text ${disabled}`, + }, + }); + + await later(); + + expect(wrapper.find('.van-calendar__confirm').html()).toMatchSnapshot(); +});