nprogress.js
说明:
nprogress是基于jquery的,且版本要 >1.8
下载地址:
api:
nprogress.start() — 启动进度条 nprogress.set(0.4) — 将进度设置到具体的百分比位置 nprogress.inc() — 少量增加进度 nprogress.done() — 将进度条标为完成状态
使用步骤:
1. 引入
<link rel="stylesheet" type="text/css" href="css/nprogress.css" rel="external nofollow" > <script src="js/nprogress.js" type="text/javascript"></script><br>//还有jquery要之前引入进来
2. 使用场景一:页面加载的效果 开始页面加载开始进度条 页面加载好 结束进度条:
<em id="__mcedel"><script> $(function() { nprogress.start(); $(window).load(function() { nprogress.done(); }); </script> </em>
3.使用场景二:ajax发送的效果 开始发送开始进度条 成功后 结束进度条:
<script> $(window).ajaxstart(function () { nprogress.start(); }); $(window).ajaxstop(function () { nprogress.done(); }); </script> //技巧总结 此方法挂在window上 是为了监听项目中所有的ajax请求 //ajax事件 可参考 jquery 文档 http://jquery.cuishifeng.cn/
总结
以上所述是小编给大家介绍的jquery nprogress.js加载进度插件的简单使用方法,希望对大家有所帮助
如对本文有疑问, 点击进行留言回复!!
微信小程序wx.scanCode扫描条形码,偶尔出现条形码不正确导致查询失败
Android 入门第七讲01-数据存储(数据存储概述,文件存储(raw和asserts目录读写,data/data/包名目录读写,sdcard目录读写),SharedPreferences读写)
vue-axios系列:axios拦截器,配置请求头,配置请求参数
网友评论