SignaturePad 签名板
基于 signature_pad 库封装的 Canvas 签名板板,支持 v-model 双向绑定和清空/确认操作。
基础用法
在面板上绘制签名后点击确认获取 Base64 DataURL。
vue
<TSignaturePad v-model="signature" />自定义颜色与尺寸
通过 pen-color、:width、:height 自定义笔迹颜色和画布尺寸。
vue
<TSignaturePad pen-color="#0ca678" :width="300" :height="150" />
<TSignaturePad pen-color="#d63939" :width="300" :height="150" />禁用状态
设置 disabled 禁止绘制,适合查看已签署的签名。
vue
<TSignaturePad disabled />API
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
model-value / v-model | string | '' | 签名结果的 DataURL |
width | number | 400 | Canvas 宽度 |
height | number | 200 | Canvas 高度 |
pen-color | string | '#000000' | 笔迹颜色 |
background-color | string | '#ffffff' | 背景色 |
min-width | number | 0.5 | 最小线宽 |
max-width | number | 2.5 | 最大线宽 |
throttle | number | 16 | 节流毫秒数 |
disabled | boolean | false | 禁用签名 |
clear-text | string | '清空' | 清空按钮文案 |
confirm-text | string | '确认' | 确认按钮文案 |
Emits
| 事件 | 参数 | 说明 |
|---|---|---|
update:model-value | dataURL: string | null | v-model 更新 |
confirm | dataURL: string | 用户确认签名 |
clear | — | 用户清空签名 |
Expose
| 方法 | 说明 |
|---|---|
isEmpty() | 签名是否为空 |
toDataURL(type?, encoderOptions?) | 获取签名 DataURL |
fromDataURL(dataURL) | 从 DataURL 加载签名 |
clear() | 清空签名 |
Slots
| 插槽 | 说明 |
|---|---|
footer | 自定义底部操作按钮区 |