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.
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(); });