Pace.js会自动加载到页面中,不须要挂接到任何代码,会自动检测进度。若是你想作一些调整,你能够设置window.paceOptions
来自定义配置:ajax
paceOptions = { // Disable the 'elements' source elements: false, // Only show the progress on regular and ajax-y page navigation, // not every request restartOnRequestAfter: false }
你也能够将自定义设置放到script
标签内,例如:spa
<script data-pace-options='{ "ajax": true, "eventLag": true , "document": true}' src='./js/pace.min.js'></script>
若是你使用AMD
或者Browserify
来加载模块的话,你能够经过这样子来设置(例如:start
):rest
define(['pace'], function(pace){ pace.start({ document: false }); });
Pace.js公开的API列表:code
AMD
或者Browserify
来加载模块的话,这个会默认执行。