简体   繁体   English

如何使用 Pace.JS 获取进度百分比

[英]how to get the progress percentage with Pace.JS

I am using pace.js to load my website.我正在使用 pace.js 加载我的网站。 But i dont want to use pace.js themes.但我不想使用pace.js 主题。 I want to built my theme.我想建立我的主题。

Is there a way that i can get de progress with jquery?有什么方法可以让我使用 jquery 取得进展吗?

I know only this funciotns:我只知道这个功能:

Pace.on("start", function(){
});
Pace.on("done", function(){
})

Just add this at line 296:只需在第 296 行添加:

Pace.trigger('update', this.progress);

Then get like this:然后变成这样:

Pace.on("update", function(percent){
});

I've done like that我已经这样做了

Pace.bar.update = function(prog) {
    Pace.trigger('update', prog)
    this.progress = prog;
    return this.render();
} // override update func to trigger 'update' event

and later后来

Pace.on('update', progress => {
    console.log('progress -> ', progress);
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM