网页顶部加载进度条NProgress

2020-03-05 15:19:33 浏览数 (4)

Installation


Add [nprogress.js] and [nprogress.css] to your project.

代码语言:javascript复制
<script src='nprogress.js'></script>
<link rel='stylesheet' href='nprogress.css'/>

NProgress is available via bower and npm and spm.

代码语言:javascript复制
$ bower install --save nprogress
$ npm install --save nprogress

Basic usage

Simply call start() and done() to control the progress bar.

代码语言:javascript复制
NProgress.start();
NProgress.done();

Using [Turbolinks] or similar? Ensure you're using Turbolinks 1.3.0 , and use this: (explained here)

代码语言:javascript复制
$(document).on('page:fetch',   function() { NProgress.start(); });
$(document).on('page:change',  function() { NProgress.done(); });
$(document).on('page:restore', function() { NProgress.remove(); });

1 人点赞