我已经添加了pace.js和pace.css到我的网站。
正如佩斯网站上所指出的,我所需要做的就是尽早在header元素中添加.js和.css,所以我做到了:
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET Application</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta content="" name="description" />
<meta content="" name="author" />
<script src="~/Scripts/global/pace.min.js"></script>
<link href="~/Content/global/pace-theme-flash.css" rel="stylesheet" />问题是,它从来没有达到100%:
<div class="pace pace-active"><div class="pace-progress" data-progress-text="99%" data-progress="99" style="transform: translate3d(100%, 0px, 0px);">
<div class="pace-progress-inner"></div>
</div>
<div class="pace-activity"></div></div>网络选项卡中没有挂起的内容,控制台中也没有错误。
我在这里错过了什么?
发布于 2017-05-10 09:28:47
这是解决办法。在这段代码中,我将检查一下每100‘s前进一次的进度。如果它已经是99(%),我将加一个计数器(counter++)。然后,每次它运行这个间隔,我也将检查计数器是否已经50,这意味着,如果是真的,那么我已经检查了当前的进展&它是99%的5秒(50x100‘s),并停止速度。
var initDestroyTimeOutPace = function() {
var counter = 0;
var refreshIntervalId = setInterval( function(){
var progress;
if( typeof $( '.pace-progress' ).attr( 'data-progress-text' ) !== 'undefined' ) {
progress = Number( $( '.pace-progress' ).attr( 'data-progress-text' ).replace("%" ,'') );
}
if( progress === 99 ) {
counter++;
}
if( counter > 50 ) {
clearInterval(refreshIntervalId);
Pace.stop();
}
}, 100);
}
initDestroyTimeOutPace();发布于 2022-10-13 15:26:11
//只显示常规页面导航和ajax-y页面导航的进度,而不是显示每个请求
数据空间-选项={“eventLag”:false,"restartOnRequestAfter":false}‘
https://stackoverflow.com/questions/43887415
复制相似问题