ionic 圆形进度条

作者: 亦久亦韭 | 来源:发表于2018-05-14 14:31 被阅读62次

1.安装

npm install progressbar.js

2.html页面

<div class="con_pro"></div>
 

3.ts页面上

import * as ProgressBar from "progressbar.js";

ngAfterViewChecked() {

let items = document.getElementsByClassName("con_pro");

for (let i = 0; i < items.length; i++) {

let a = items[i].getAttribute("id");

let b = document.getElementById(a);

if (b.innerHTML.trim().length == 0) {

this.doline(a, 50);

}

}

}

doline(id, stopval) {

let circle = new ProgressBar.Circle("#" + id, {

color: "red",

duration: 3000,

easing: "easeInOut",

from: { color: "#aaa", width: 10 },

to: { color: "#333", width: 10 },

strokeWidth: 10,

trailWidth: 10,

step: function(to, circle) {

let value = Math.round(circle.value() * 100);

circle.setText(value + "%");

if (value >= stopval) {

circle.stop();

}

}

});

circle.animate(1);

}

相关文章

网友评论

    本文标题:ionic 圆形进度条

    本文链接:https://www.haomeiwen.com/subject/jqtjdftx.html