<style>
.schedule{
width: 0;
height: 30px;
background: orange;
line-height: 30px;
text-align: center;
font-weight: bold;
}
</style>
<div class="schedule"></div>
<script>
function task() {
const dom = document.querySelector('.schedule')
let s = 0;
(function run(){
++s;
if(s <= 100) {
dom.innerHTML = s + '%';
dom.style.width = s + 'px';
// 关键所在
setTimeout(run, 200);
}
})()
}
task()
</script>
简单进度条实现思路
最新推荐文章于 2024-07-26 20:46:33 发布