城市直播房产教育博客汽车
投稿投诉
汽车报价
买车新车
博客专栏
专题精品
教育留学
高考读书
房产家居
彩票视频
直播黑猫
投资微博
城市上海
政务旅游

一文解读前端实现电子签名

12月24日 浅时光投稿
  大家好,我是Echa。
  创作不易,喜欢的老铁们加个关注,点个赞,后面会持续更新干货,速速收藏,谢谢!
  在现在的时代发展中,从以前的手写签名,逐渐衍生出了电子签名。电子签名和纸质手写签名一样具有法律效应。电子签名目前主要还是在需要个人确认的产品环节和司法类相关的产品上较多。
  举个常用的例子,大家都用过钉钉,钉钉上面就有电子签名,相信大家这肯定是知道的。
  那作为前端的我们如何实现电子签名呢?其实在html5中已经出现了一个重要级别的辅助标签,是啥呢?那就是canvas。下面我给大家分享分享几个关于前端如何实现电子签名经典案例以及实现方法。什么是canvas
  Canvas(画布)是在HTML5中新增的标签用于在网页实时生成图像,并且可以操作图像内容,基本上它是一个可以用JavaScript操作的位图(bitmap)。Canvas对象表示一个HTML画布元素。它没有自己的行为,但是定义了一个API支持脚本化客户端绘图操作。
  大白话就是canvas是一个可以在上面通过javaScript画图的标签,通过其提供的context(上下文)及Api进行绘制,在这个过程中canvas充当画布的角色。实现电子签名
  知道几何的朋友都很清楚,线由点绘成,面由线绘成。
  多点成线,多线成面。
  所以我们实际只需要拿到当前触摸的坐标点,进行成线处理就可以了。全文大纲vueimg02。bs178。comblxh233f4def5c875875。jpgcanvas一个基于canvas开发,封装于Vue组件的通用手写签名板img02。bs178。comblxh233f4def5c875875。jpgaturePad是一个用于绘制平滑签名的JavaScript库。纯JavaScript实现电子签名,同时支持Web端和移动端。vueimg02。bs178。comblxh233f4def5c875875。jpgcanvas
  在线预览:https:langyuxiansheng。github。iovueimg02。bs178。comblxh233f4def5c875875。jpgcanvas
  Github:https:github。comlangyuxianshengvueimg02。bs178。comblxh233f4def5c875875。jpgcanvas
  vueimg02。bs178。comblxh233f4def5c875875。jpgcanvas一个基于canvas开发,封装于Vue组件的通用手写签名板(电子签名板),支持pc端和移动端,属性支持自定义配置
  组件模板使用templateh2classtitleVueimg02。bs178。comblxh233f4def5c875875。jpgCanvas电子签名板h2img02。bs178。comblxh233f4def5c875875。jpgcanvasclassimg02。bs178。comblxh233f4def5c875875。jpgcanvasrefimg02。bs178。comblxh233f4def5c875875。jpgCanvas:optionsoptionsvmodelimg02。bs178。comblxh8d6e0baf80249c42。jpgimgvifimg02。bs178。comblxh8d6e0baf80249c42。jpgclassviewimage:srcimg02。bs178。comblxh8d6e0baf80249c42。jpgwidth150height150ulclassulconfigliclasslicspanclassitemlabel书写速度:spanspanclassitemcontentselectnameisimg02。bs178。comblxh233f4def5c875875。jpgvmodeloptions。isimg02。bs178。comblxh233f4def5c875875。jpgoption:img02。bs178。comblxh8d6e0baf80249c42。jpgtrue签名optionoption:img02。bs178。comblxh8d6e0baf80249c42。jpgfalse写字optionselectspanliliclasslicspanclassitemlabel显示边框网格:spanspanclassitemcontentselectnameisimg02。bs178。comblxh233f4def5c875875。jpgvmodeloptions。isShowBorderoption:img02。bs178。comblxh8d6e0baf80249c42。jpgtrue显示optionoption:img02。bs178。comblxh8d6e0baf80249c42。jpgfalse不显示optionselectspanliliclasslicspanclassitemlabel兼容高倍屏高清绘制:spanspanclassitemcontentselectnameisimg02。bs178。comblxh233f4def5c875875。jpgvmodeloptions。isDproption:img02。bs178。comblxh8d6e0baf80249c42。jpgtrue启用optionoption:img02。bs178。comblxh8d6e0baf80249c42。jpgfalse关闭optionselectspanliliclasslicspanclassitemlabel边框宽度:spanspanclassitemcontentinputvmodeloptions。borderWidthtypenumberspanliliclasslicspanclassitemlabel下笔宽度:spanspanclassitemcontentinputvmodeloptions。writeWidthtypenumberspanliliclasslicspanclassitemlabel图片类型:spanspanclassitemcontentinputvmodeloptions。imgTypetypetextspanliliclasslicspanclassitemlabel线条的边缘类型:spanspanclassitemcontentselectnamelineCapvmodeloptions。lineCapoptionimg02。bs178。comblxh8d6e0baf80249c42。jpgbutt平直的边缘optionoptionimg02。bs178。comblxh8d6e0baf80249c42。jpground圆形线帽optionoptionimg02。bs178。comblxh8d6e0baf80249c42。jpgsquare正方形线帽optionselectspanliliclasslicspanclassitemlabel线条交汇时边角的类型:spanspanclassitemcontentselectnamelineCapvmodeloptions。lineJoinoptionimg02。bs178。comblxh8d6e0baf80249c42。jpgbevel创建斜角optionoptionimg02。bs178。comblxh8d6e0baf80249c42。jpground创建圆角optionoptionimg02。bs178。comblxh8d6e0baf80249c42。jpgmiter创建尖角optionselectspanliliclasslicspanclassitemlabel画笔颜色:spanspanclassitemcontentinputtypecolorvmodeloptions。writeColorspanliliclasslicspanclassitemlabel背景色:spanspanclassitemcontentinputtypecolorvmodeloptions。bgColorspanliulspanidclearclickcanvasClear()清空spanspanidsaveclicksaveAsImg()保存spanspanidsaveclickdownloadimg02。bs178。comblxh233f4def5c875875。jpgImg()下载spantemplatestylelangless{margin:0;padding:0;}。title{padding:20textalign:}。img02。bs178。comblxh233f4def5c875875。jpgcanvas{display:margin:20}。viewimage{display:margin:20}。config{width:350margin:20。ulconfig{。lic{display:alignitems:padding:4px10。itemlabel{fontsize:14}。itemcontent{marginleft:10}}}}。img02。bs178。comblxh233f4def5c875875。jpgbtns{display:justifycontent:clear,clear1,save{display:padding:5px10width:76height:40lineheight:40border:1background:e1e1e1;borderradius:10textalign:margin:20cursor:}}style横屏全屏模式下签名要怎么显示?templatevifimg02。bs178。comblxh233f4def5c875875。jpgimgclassimg02。bs178。comblxh233f4def5c875875。jpgimage:srcimg02。bs178。comblxh233f4def5c875875。jpgaltsrcsettemplatestylelangscssscoped。userimg02。bs178。comblxh233f4def5c875875。jpg{background:e7e7e7;height:9。375position:。img02。bs178。comblxh233f4def5c875875。jpgimage{margin:0zindex:9;height:100;transform:rotate(90deg)scale(1。5);display:}}style
  如下图:
  img02。bs178。comblxh233f4def5c875875。jpgaturePad
  在线预览:http:szimek。github。ioimg02。bs178。comblxh233f4def5c875875。jpgaturepad
  Github:https:github。comszimekimg02。bs178。comblxh233f4def5c875875。jpgaturepad
  img02。bs178。comblxh233f4def5c875875。jpgaturePad是一个用于绘制平滑签名的JavaScript库。它基于HTML5画布,使用基于Square发布的Smootherimg02。bs178。comblxh233f4def5c875875。jpgatures的可变宽度Bzier曲线插值。它适用于所有现代桌面和移动浏览器,不依赖任何外部库。
  核心代码:constcanvasdocument。querySelector(canvas);constimg02。bs178。comblxh233f4def5c875875。jpgaturePadnewimg02。bs178。comblxh233f4def5c875875。jpgaturePad(canvas);Returnsimg02。bs178。comblxh233f4def5c875875。jpgatureimageasdataURL(seehttps:mdn。iotodataurlforthelistofpossibleparameters)img02。bs178。comblxh233f4def5c875875。jpgaturePad。toDataURL();saveimageasPNGimg02。bs178。comblxh233f4def5c875875。jpgaturePad。toDataURL(imagejpeg);saveimageasJPEGimg02。bs178。comblxh233f4def5c875875。jpgaturePad。toDataURL(imagejpeg,0。5);saveimageasJPEGwith0。5imagequalityimg02。bs178。comblxh233f4def5c875875。jpgaturePad。toDataURL(imagesvgxml);saveimageasSVGdataurlReturnsvgstringwithoutconvertingtobase64img02。bs178。comblxh233f4def5c875875。jpgaturePad。toSVG();svg。。。svgimg02。bs178。comblxh233f4def5c875875。jpgaturePad。toSVG({includeBackgroundColor:true});addbackgroundcolortosvgoutputDrawsimg02。bs178。comblxh233f4def5c875875。jpgatureimagefromdataURL(mostlyuseshttps:mdn。iodrawImageunderthehood)NOTE:Thismethoddoesnotpopulateinternaldatastructurethatrepresentsdrawnimg02。bs178。comblxh233f4def5c875875。jpgature。Thus,afterusingfromDataURL,toDatawontworkproperly。img02。bs178。comblxh233f4def5c875875。jpgaturePad。fromDataURL(data:base64,iVBORw0K。。。);Drawsimg02。bs178。comblxh233f4def5c875875。jpgatureimagefromdataURLandaltersitwiththegivenoptionsimg02。bs178。comblxh233f4def5c875875。jpgaturePad。fromDataURL(data:base64,iVBORw0K。。。,{ratio:1,width:400,height:200,xOffset:100,yOffset:50});Returnsimg02。bs178。comblxh233f4def5c875875。jpgatureimageasanarrayofpointgroupsconstdataimg02。bs178。comblxh233f4def5c875875。jpgaturePad。toData();Drawsimg02。bs178。comblxh233f4def5c875875。jpgatureimagefromanarrayofpointgroupsimg02。bs178。comblxh233f4def5c875875。jpgaturePad。fromData(data);Drawsimg02。bs178。comblxh233f4def5c875875。jpgatureimagefromanarrayofpointgroups,withoutclearingyourexistingimage(cleardefaultstotrueifnotprovided)img02。bs178。comblxh233f4def5c875875。jpgaturePad。fromData(data,{clear:false});Clearsthecanvasimg02。bs178。comblxh233f4def5c875875。jpgaturePad。clear();Returnstrueifcanvasisempty,otherwisereturnsfalseimg02。bs178。comblxh233f4def5c875875。jpgaturePad。isEmpty();Unbindsalleventhandlersimg02。bs178。comblxh233f4def5c875875。jpgaturePad。off();Rebindsalleventhandlersimg02。bs178。comblxh233f4def5c875875。jpgaturePad。on();
  如下图:
  纯JavaScript实现电子签名
  完整版:!DOCTYPEhtmlhtmllangenheadmetacharsetUTF8metahttpequivXUACompatiblecontentIEedgemetanameviewportcontentwidthdevicewidth,initialscale1。0titleDocumenttitlestyle{margin:0;padding:0;}styleheadbodycanvascanvasbuttononclickcancel()取消buttonbuttononclicksave()保存buttonbodyhtml各内核和浏览器支持情况
  Mozilla程序从Gecko1。8(Firefox1。5(enUS))开始支持。它首先是由Apple引入的,用于OSXDashboard和Safari。InternetExplorer从IE9开始支持,更旧版本的IE中,页面可以通过引入Google的ExplorerCanvas项目中的脚本来获得支持。GoogleChrome和Opera9也支持。小程序中提示
  在小程序中我们如果需呀实现的话,也是同样的原理哦,只是我们需要将创建实例和上下文的Api进行修改,因为小程序中是没有dom,既然没有dom,哪来的操作dom这个操作呢。如果是uniapp则需要使用uni。createCanvasContext进行上下文创建如果是原生微信小程序则使用wx。createCanvasContext进行创建(2。9。0)之后的库不支持
投诉 评论 转载

火车可以实现全覆盖吗目前铁路总公司安全出行、方便出行、温馨出行要求,完善旅客普速列车客运服务功能,拓展客运延伸服务业务,日前,铁路局全面开通普速旅客列车WIFI服务。一些人问:火车可以实现WIFI……中超积分榜变化泰山暂居第一国安提前无缘赛季前四名齐鲁网闪电新闻12月27日讯山东电视体育频道消息,12月27日,中超官方公告,北京国安申请对上海海港的第33轮比赛弃权,被判03负。在放弃本轮对阵海港的联赛后,北京国安已经提前……遇见碎片化的生活碎片化的生活,一看到这六个字的时候,我就想到了陈景润,他是一个将碎片时间利用得最有效的人。知道陈景润还是在四年级的语文书课本里学到的。他不管是在上厕所,吃饭,等车,等图书馆开门……非常实用,戴森加湿器深度清洗和大家分享一下这款戴森加湿器的深度清理步骤:分三部分进行拆解清理:首先是出风口部分,即图片中的1部分把出风口边缘的圈部分拆下来,是卡口固定,能比较轻松的拆下来……如何利用电子档案服务于高职院校行政管理工作【摘要】在信息化时代,我国电子档案开始应用到社会的各个领域,促使其价值得到充分发挥。因为电子档案的使用,各行业具备更大的发展优势;将其应用到日常管理工作中,能为整体提供方便。将……iPhone14Pro全系破发,不用等了自iPhone14系列发布以来,真的卖疯了。根据研究机构Counterpoint的统计,今年第三季度全球智能手机市场营收达到了1000亿美元(约6960亿元人民币)。……大学生校园生活存在哪些安全隐患校园安全一直是我们比较关注的热点话题,学生的安全直接关系着国家未来人才的选择,我国一直都比较重视学生的安全教育工作,然而,校园安全事故还是一再发生。那么,大学生校园生活存在哪些……一文解读前端实现电子签名大家好,我是Echa。创作不易,喜欢的老铁们加个关注,点个赞,后面会持续更新干货,速速收藏,谢谢!在现在的时代发展中,从以前的手写签名,逐渐衍生出了电子签名。电子签……再到造句用再到造句大全61,从八宝山到木樨地,再到现在这个我完全找不着北的地方,这一路折腾完,我实在不知道我现在到哪儿了。62,汤原断陷古近系湖盆经历了由小到大再到小的过程。63,与此同……青黛四物茶清热养血祛风镇惊功效青黛四物茶原料:青黛0。3g、当归3g、生地3g、白芍3g、川芎3g、花茶5g。用法:用300ml水煎煮当归、生地、白芍、川芎至水沸后,冲泡青黛、花茶即可。也可直接……热得造句用热得造句大全151、这天,翠枝一大早就去自家的稻田里除草,忙到午时,她热得实在受不住了,只好上了田岸。152、天闷得很,开了空调后背疼,不开空调,热得让人烦燥啊。153、天天在……女人与情书情书对女人的真正魅力,不在情书本身,而在情书调动起来的女人丰富的联想。女人看似在情书的字里行间漫游,实际上,早已被情感的波涛掀上浪峰,又抛进浪谷,不由自主地掉进了感情的漩涡。……
故宫为什么不要去三次?什么时候敷面膜最好?宝妈找月嫂要求必须接受和宝爸同住屋里有监控,卧室门打开14款违法APP被点名,快看看你的手机有没有粤浙赛后!周鹏表态劳模,杜锋送上放假,徐杰谢教练组摊牌辽宁破案了!广厦拿下开门红,赛后王哲林扭头就走,为何不握手?2023款特斯拉Roadster曝光,三电机全轮驱动,扭矩爆34岁老将!场均5分4。6篮板,拿顶薪,俱乐部高层回应了遗传承这几个民间庙会热闹非凡,流传至今津媒国足需严防对手角球定位球不要在同一问题上屡次犯错他拥有高颜值女友,坐稳国乒主力位置,竞争国乒一哥还得看樊振东王者荣耀轰隆隆大作战最强英雄选什么好王者荣耀轰隆隆大作战英雄
美背的海绵需要洗吗美背的海绵需不需要洗苹果也有失败的iPhone,比mini还惨,堪比iPhone 起诉离婚什么条件才能确定好地点热博聚热点网 党史学习教育专题组织生活会个人发言材料新海洋的诞生地一次科学实验玲珑四犯登德清玉尘峰浮远楼雾霾是怎么形成的解析形成雾霾的个主要原因新春走基层点亮乡村孩子的梦想热议聚热点网 吉富星:调节收入差距应更加注重机会均等阈值造句用阈值造句大全二难推理的简单破坏式:特点例子、推理形式

友情链接:中准网聚热点快百科快传网快生活快软网快好知文好找江西南阳嘉兴昆明铜陵滨州广东西昌常德梅州兰州阳江运城金华广西萍乡大理重庆诸暨泉州安庆南充武汉辽宁