基于canvas的手写插件(移动端和pc端均可使用)
npm install mobile-graphics --saveconst Graphics = require('mobile-graphics');
const graphics = new Graphics({
el: document.getElementById('canvas'), // 挂载节点
linewidth: 2, // 线条宽度
color: '#000', // 线条颜色
background: '#fff' // 背景颜色
}){
el: document.getElementById('canvas'), // 挂载节点(必填)
linewidth: 2, // 线条宽度
color: '#000', // 线条颜色
background: '#fff' // 背景颜色
}graphics.clear() // 清空画布
graphics.previous() // 返回上一步
graphics.save() // 保存画布(该函数会直接返回一个base64)