当前位置:网站首页>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
}
边栏推荐
猜你喜欢
随机推荐
P3 元宝第三天的笔记
MongoDB快速入门与基本使用
用h1~h5标题时候,但是如果不要加粗的效果,处理方法如下
argparse —— 命令行选项、参数和子命令解析器
Anaconda安装教程
list(列表)和array(数组)的区别
信号量解决生产者消费者问题
自定义异常类的使用
三子棋游戏——C语言
I/O多路复用技术
“tensorflow.keras.preprocessing“ has no attribute “image_dataset_from_directory“
torch.optim.Adam()
VS2022中关于scanf函数报错解决方法
Memories · The last system design in the university era
C语言(入门篇一)
C语言指针(指针数组、数组指针、函数指针、传参、回调函数等)超详细
St. Regis Takeaway Project: New dishes and dishes paged query
How is crawler data collected and organized?
torch.load()
Ranking of grades (Huazhong University of Science and Technology postgraduate examination questions) (DAY 87)









