Skip to content

Commit 7328123

Browse files
committed
feat(signature): support tips slot
1 parent 1e390af commit 7328123

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

packages/vant/src/signature/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ Use `background-color` prop to set the color of the background.
9999
| submit | Emitted when clicking the confirm button | _data: { image: string; canvas: HTMLCanvasElement }_ |
100100
| clear | Emitted when clicking the cancel button | - |
101101

102+
### Slots
103+
104+
| Name | Description | SlotProps |
105+
| ---- | ----------- | --------- |
106+
| tips | Custom tips | - |
107+
102108
### Methods
103109

104110
Use [ref](https://vuejs.org/guide/essentials/template-refs.html) to get Signature instance and call instance methods.

packages/vant/src/signature/README.zh-CN.md

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ export default {
9999
| submit | 点击确定按钮时触发 | _data: { image: string; canvas: HTMLCanvasElement }_ |
100100
| clear | 点击取消按钮时触发 | - |
101101

102+
### Slots
103+
104+
| 名称 | 说明 | 参数 |
105+
| ---- | -------------- | ---- |
106+
| tips | 自定义提示文案 | - |
107+
102108
### 方法
103109

104110
通过 ref 可以获取到 Signature 实例并调用实例方法,详见[组件实例方法](#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa)

packages/vant/src/signature/Signature.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default defineComponent({
5353

5454
emits: ['submit', 'clear', 'start', 'end', 'signing'],
5555

56-
setup(props, { emit }) {
56+
setup(props, { emit, slots }) {
5757
const canvasRef = ref<HTMLCanvasElement>();
5858
const wrapRef = ref<HTMLElement>();
5959
const ctx = computed(() => {
@@ -195,6 +195,8 @@ export default defineComponent({
195195
onTouchmove={touchMove}
196196
onTouchend={touchEnd}
197197
/>
198+
) : slots.tips ? (
199+
slots.tips()
198200
) : (
199201
<p>{props.tips}</p>
200202
)}

0 commit comments

Comments
 (0)