效果如下:
源代码
代码比较简单,注释也比较清晰
<template>
<view >
<canvas class="mycanvas" canvas-id="mycanvas" @touchstart="touchstart" @touchmove="touchmove" @touchend="touchend"></canvas>
<view class="footer">
<view class="left" @click="finish" style="width: 100%;">确定</view>
</view>
</view>
</template>
<script>
var x = 20;
var y =20;
export default{
data(){
return {
ctx: '', //绘图图像
points: [], //路径点集合
isEnd: false, // 是否结束签名
}
},
created() {
this.ctx = uni.createCanvasContext("mycanvas",this); //创建绘图对象
//设置画笔样式
this.ctx.lineWidth =