当前位置:网站首页>js 实现自定义签名
js 实现自定义签名
2022-07-30 05:40:00 【勿扰丶】
通过canvas实现自定义签名
- List item
// 结构
<div id="myChart" :style="{width: '600px', height: '300px'}"></div>
<button @click="submit"> 提交 </button>
// js部分
function init(){
let canvas = document.getElementById('can')
canvas.width = 300
canvas.height = 500
let ctx = canvas.getContext('2d')
ctx.strokeStyle = '#000'
ctx.lineWidth = 1
canvas.addEventListener('touchstart', (e) => {
ctx.beginPath()
ctx.moveTo(e.touches[0].pageX, e.touches[0].pageY)
})
canvas.addEventListener('touchmove', (e) => {
ctx.lineTo(e.touches[0].pageX, e.touches[0].pageY)
ctx.stroke()
})
canvas.addEventListener('touchend', (e) => {
ctx.closePath()
})
}
function submit () {
let blank = document.createElement('canvas')
let canvas = document.getElementById('can')
blank.width = canvas.width
blank.height = canvas.height
// 新创建一个画布 判断是否相等 相等为true
}
边栏推荐
- net start mysql MySQL service is starting. MySQL service failed to start.The service did not report any errors.
- 面试前需要巩固的算法知识点(自用,更新中)
- C语言入门(前期准备工作)——超级详细的建议和教学,带你顺利跨越编程门槛
- 函数解剖——深挖getchar()与putchar()
- [详解C语言]一文带你玩转数组
- 5.6EPOLLONESHOT事件
- 【线性神经网络】线性回归 / 基础优化方法
- Different usage scenarios of subqueries as retrieval tables and the question of whether to add aliases
- mysql处理insert冲突的解决方案
- async/await用法详解
猜你喜欢
随机推荐
k折交叉验证(k-fold Cross-validation)
面试前需要巩固的算法知识点(自用,更新中)
MySQL database basics (a systematic introduction)
union中有struct的情况-从内存分析
ezTrack-master使用教程
flask使用token认证
分支和循环语句
240.搜索二维矩阵II
Error: listen EADDRINUSE: address already in use 127.0.0.1:3000
最新版redis6.3.2下载安装
strlen和sizeof的区别
50道SQL练习题(刷完直接进大厂)
Arrange numbers (DAY90) dfs
Application Practice | Application Practice of Apache Doris in Baidu Intelligent Cloud Billing System
【飞控开发基础教程9】疯壳·开源编队无人机-PWM(电机控制)
互斥量解决线程同步问题
微积分 / 自动求导
Anaconda安装教程
“tensorflow.keras.preprocessing“ has no attribute “image_dataset_from_directory“
5.5线程池







![[Other] DS5](/img/20/6863bb7b58d2e60b35469ba32e5830.png)

