进度条
参数说明:
| 参数 | 说明 | 类型 | 可选值 |
| ele_id | 挂载元素的id | String | 必填 |
| bgcolor | 进度条背景色 | String | 默认值#f57e00 |
| istext | 是否显示文字百分比:true显示,false不显示 | boolean | 默认值false |
| fontsize | 设置文字大小 | String | 默认值14px |
| fontcolor | 设置文字颜色 | String | 默认值#333 |
| position | 设置文字显示位置:可选centertop,bottom,left,right | String | 默认值center |
| percent | 设置百分比 | Int | 默认值100 |
| size | 设置进度条的高度 | String | 默认值20px |
动态修改百分比方法:
| 参数 | 说明 | 类型 | 可选值 |
| ele_id | 挂载元素的id | String | 必填 |
| percent | 设置百分比 | Int | —— |
// percent动态修改的百分比
McrbHttpClient.progress.change({
ele_id:'progress_bar',
percent: percent,
},function(e){
// console.log('当前进度是'+e);
});
用法实例:
<div id="progress_bar"></div>
// 进度条
McrbHttpClient.progress.init({
ele_id:'progress_bar',
bgcolor:'#f57e00',
istext:true,
fontsize:'12px',
fontcolor:'#0069ff',
position:'right',
percent: 0,
size:'20px',
});
var percent = 0;
var timer = setInterval(function(){
// 这里采用随机的两位数来模拟
var a = Math.floor(Math.round(Math.random()*(100-10)+10)/10);
percent = percent+a;
// console.log(percent)
if(percent>100){
percent = 100;
clearInterval(timer);
}
McrbHttpClient.progress.change({
ele_id:'progress_bar',
percent: percent,
},function(e){
// console.log('当前进度是'+e);
});
},1000);
效果展示:
扫一扫