<div id=app>
<canvas id="deposit_canvas" class="deposit_canvas" ></canvas>
</div>
var app = new Vue({
el : '#app',
data : {
process : 0
},
methods : {
//渐变进度环
shadowRing : function () {
var canvas =document.querySelector('.deposit_canvas');
canvas.width = 150;
canvas.height = 150;
var ctx = canvas.getContext('2d');
ctx.lineWidth = 5;
// 画灰色的圆
ctx.beginPath();
ctx.moveTo(145,75);
ctx.strokeStyle = '#F6F6F6';
ctx.arc(75,75,70,0, Math.PI * 2);
ctx.stroke();
animate();
function animate(){
requestAnimationFrame(function (){
app.process += 1 ;
drawCricle(ctx, app.process);
if (app.process < 100) {
animate();
}
});
}
function drawCricle(ctx, percent) {
//画进度环
ctx.beginPath();
ctx.moveTo(75,5);
var grd=ctx.createLinearGradient(0,0,150,150);
grd.addColorStop(0,"#fea800");
grd.addColorStop(1,"#ff7c00");
ctx.strokeStyle = grd;
ctx.arc(75,75,70,Math.PI * 1.5, Math.PI * (1.5 + 2 * percent / 100 ));
ctx.stroke();
}
},
mounted : function() {
this.shadowRing();
}
});
