xxx.hml
<div class="container" >
<div class="card">
<div class="prize-box">
<!-- 开奖区域-->
<text class="text">
{{ prize }}
</text>
<!-- 刮刮乐涂层-->
<canvas ref="canvas" style="width:202px;height:43px;" @touchstart="touchstart"
@touchmove="touchmove" @touchend="touchend" @touchcancel="touchcancel" class="canvas"></canvas>
</div>
</div>
</div>
xxx.js
onShow(){
this.draw();
},
draw(){
var el = this.$refs.canvas;
var ctx = el.getContext('2d',{ antialias: true });
this.el = el
this.ctx = ctx
//填充的颜色
ctx.fillStyle = 'gray';
//填充矩形 fillRect(起始X,起始Y,终点X,终点Y)
ctx.fillRect(0, 0, 202, 43);
this.ctx.fillStyle = '#000';
//绘制填充文字
this.ctx.font = "28px";
this.ctx.fillText('刮开有奖', 50, 30);
},
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |