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(); }