From d1a71dd6e75e9ea5174b7dd9213245b7bdc52b2c Mon Sep 17 00:00:00 2001 From: chouchouji <70570907+chouchouji@users.noreply.github.com> Date: Sat, 15 Mar 2025 19:49:16 +0800 Subject: [PATCH] feat(signature): support tips slot (#13385) --- packages/vant/src/signature/README.md | 6 ++++++ packages/vant/src/signature/README.zh-CN.md | 6 ++++++ packages/vant/src/signature/Signature.tsx | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/vant/src/signature/README.md b/packages/vant/src/signature/README.md index 08b4ef898..01c28d342 100644 --- a/packages/vant/src/signature/README.md +++ b/packages/vant/src/signature/README.md @@ -99,6 +99,12 @@ Use `background-color` prop to set the color of the background. | submit | Emitted when clicking the confirm button | _data: { image: string; canvas: HTMLCanvasElement }_ | | clear | Emitted when clicking the cancel button | - | +### Slots + +| Name | Description | SlotProps | +| ---- | ----------- | --------- | +| tips | Custom tips | - | + ### Methods Use [ref](https://vuejs.org/guide/essentials/template-refs.html) to get Signature instance and call instance methods. diff --git a/packages/vant/src/signature/README.zh-CN.md b/packages/vant/src/signature/README.zh-CN.md index 3ab70b9b4..e76422c9e 100644 --- a/packages/vant/src/signature/README.zh-CN.md +++ b/packages/vant/src/signature/README.zh-CN.md @@ -99,6 +99,12 @@ export default { | submit | 点击确定按钮时触发 | _data: { image: string; canvas: HTMLCanvasElement }_ | | clear | 点击取消按钮时触发 | - | +### Slots + +| 名称 | 说明 | 参数 | +| ---- | -------------- | ---- | +| tips | 自定义提示文案 | - | + ### 方法 通过 ref 可以获取到 Signature 实例并调用实例方法,详见[组件实例方法](#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa)。 diff --git a/packages/vant/src/signature/Signature.tsx b/packages/vant/src/signature/Signature.tsx index 2a52ba95b..390f66bef 100644 --- a/packages/vant/src/signature/Signature.tsx +++ b/packages/vant/src/signature/Signature.tsx @@ -53,7 +53,7 @@ export default defineComponent({ emits: ['submit', 'clear', 'start', 'end', 'signing'], - setup(props, { emit }) { + setup(props, { emit, slots }) { const canvasRef = ref(); const wrapRef = ref(); const ctx = computed(() => { @@ -195,6 +195,8 @@ export default defineComponent({ onTouchmove={touchMove} onTouchend={touchEnd} /> + ) : slots.tips ? ( + slots.tips() ) : (

{props.tips}

)}