引入:
<link href="https://www.haohaokan17.com/js/nprogress.css" rel="stylesheet" />
<script src="https://www.haohaokan17.com/static/js/jquery.min.js"></script>
<script src="https://www.haohaokan17.com/js/nprogress.js"></script>
html:
<div class="progress">
<div></div>
</div>
css:
<style>
.progress { width: 100%; height: 1px; }
.progress div { width: 0; height: 100%; background: green; transition: width .5s;}
</style>
js:
document.addEventListener('readystatechange', function () {
if(document.readyState === 'interactive') {
document.querySelector('.progress div').style.width = '33%'
}
if(document.readyState === 'complete') {
document.querySelector('.progress div').style.width = '66%'
}
} )
window.onload = function () {
document.querySelector('.abc div').style.width = '100%'
}