【问题标题】:how to get the progress percentage with Pace.JS如何使用 Pace.JS 获取进度百分比
【发布时间】:2020-03-23 05:34:35
【问题描述】:

我正在使用 pace.js 加载我的网站。但我不想使用pace.js 主题。我想建立我的主题。

有什么方法可以让我使用 jquery 取得进展吗?

我只知道这个功能:

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

【问题讨论】:

    标签: jquery pace


    【解决方案1】:

    只需在第 296 行添加:

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

    然后变成这样:

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

    【讨论】:

    • 发现自己多次访问这个确切的答案。 Pace 确实可以添加这个不错的功能。
    【解决方案2】:

    我已经这样做了

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

    以后

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

    【讨论】:

      猜你喜欢
      • 2014-10-12
      • 2020-03-23
      • 1970-01-01
      • 2015-06-28
      • 2015-07-12
      • 2012-06-16
      • 2020-11-27
      • 1970-01-01
      • 2011-05-19
      相关资源
      最近更新 更多