微信小程序用canvas 绘制虚线
作者:互联网
1:效果图
代码:
<canvas
style="width: 300px; height: 1rpx;"
canvas-id="firstCanvas"
class="line"
></canvas>
// 绘制一条虚线
drawLine() {
var context = wx.createCanvasContext('firstCanvas');
context.setLineDash([8, 15]);
context.lineWidth = 2;
context.strokeStyle = '#979797';
context.beginPath();
context.moveTo(0, 0);
context.lineTo(740, 0);
context.stroke();
context.draw();
}
created() {
this.drawLine();
}
标签:740,canvas,drawLine,微信,moveTo,虚线,context,绘制 来源: https://blog.csdn.net/qq_44170622/article/details/116212529