1.0.4 • Published 1 month ago

@tanzhenxing/zx-sign v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
1 month ago

zx-sign 电子签名组件

基于 uniapp 的多端(H5/小程序/App)手写签名组件,支持自定义画布大小、颜色、线宽,支持签名确认、重置、图片导出。

组件特性

  • 支持 H5、微信/支付宝/百度/QQ/抖音小程序、App(vue3)
  • 纯 uniapp API 实现,无浏览器特有 DOM
  • 支持自定义画布宽高、背景色、线条颜色、线宽
  • 支持签名确认、重置、图片导出
  • 事件回调丰富

属性(Props)

属性名类型默认值说明
orientationStringportrait屏幕方向
canvas-idStringmySign画布 id
widthString''画布宽度(rpx)
heightString''画布高度(rpx)
background-colorString#ececec画布背景色
line-colorString#333333画笔颜色
line-sizeString5rpx画笔大小

事件(Events)

事件名说明回调参数
change签名内容变更时触发{ tempFilePath }
confirm点击确认签名时触发签名图片临时路径 string

方法(ref 调用)

方法名说明
confirm触发确认签名
canvasInit重置签名

基本用法

<template>
  <zx-sign
    ref="signRef"
    :canvas-id="'mySignDemo'"
    :width="'600rpx'"
    :height="'300rpx'"
    :background-color="'#fff'"
    :line-color="'#007AFF'"
    :line-size="'8rpx'"
    @change="onSignChange"
    @confirm="onSignConfirm"
  />
</template>

<script setup>
import { ref } from 'vue'
import zxSign from '@/components/zx-sign/zx-sign.vue'

const signRef = ref(null)
function onSignChange(e) {
  // e.tempFilePath 为签名图片临时路径
}
function onSignConfirm(img) {
  // img 为签名图片临时路径
}
</script>

完整示例

详见 src/pages/components/sign/index.vue

注意事项

  • 组件内部不使用浏览器特有 DOM,兼容主流 uniapp 端。
  • 画布宽高建议传递 rpx 单位,适配不同屏幕。
  • 组件需在页面 onReady 后再调用 ref 方法。
1.0.4

1 month ago

1.0.3

2 months ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago