网站首页 > 知识剖析 正文
今天给大家分享一款超酷的仿yutube顶部加载进度条NProgress.js。
nprogress.js 一款类似youtube、Medium等网站上的小进度条插件。star高达22.7K。
安装/引入
通过npm方式安装插件。
$ npm i nprogress -S
通过js和css引入方式。
<script src='nprogress.js'></script>
<link rel='stylesheet' href='nprogress.css'/>
// CDN引入
https://unpkg.com/nprogress@0.2.0/nprogress.js
https://unpkg.com/nprogress@0.2.0/nprogress.css
使用
通过调用start()和done()方法即可控制进度条显示和完成。
NProgress.start()
NProgress.done()
还支持百分比和缓慢步进操作。
NProgress.set(0.6)
NProgress.inc(0.2)
在vue.js项目中可以通过如下方式调用。
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
router.beforeEach((to, from, next) => {
NProgress.start()
next()
})
router.afterEach(() => {
NProgress.done()
})
很多的网站都有使用这款进度条插件,非常适合Turbolinks, Pjax或其他Ajax密集型应用程序。
# 官网地址
https://ricostacruz.com/nprogress/
# 仓库地址
https://github.com/rstacruz/nprogress
End~ 以上就是这次的分享,感谢大家的阅读。
猜你喜欢
- 2025-09-12 在 JAVASCRIPT 中创建 HTML 元素...
- 2025-09-12 不来看看这些 VUE 的生命周期钩子函数?| 原力计划
- 2025-09-12 国外越来越多的“自拍死”:为一张美照几个赞丢命,值得么?
- 2025-09-12 CSS视觉格式化模型,你真的了解么?
- 2025-09-12 VR×GBA | From Mazu to the World: The Man Who Carved the City
- 2025-09-12 CSS面试题汇总_div css面试题
- 2025-09-12 Next.js 实战 (五):添加路由 Transition 过渡效果和 Loading 动画
- 2025-09-12 CSS :has()伪类:2025年最值得掌握的前端黑科技
- 2025-09-12 css权重及优先级规则_css权重顺序
- 2025-09-12 CSS隐藏空元素的神技::empty伪类让你的代码更优雅!
- 最近发表
- 标签列表
-
- xml (46)
- css animation (57)
- array_slice (60)
- htmlspecialchars (54)
- position: absolute (54)
- datediff函数 (47)
- array_pop (49)
- jsmap (52)
- toggleclass (43)
- console.time (63)
- .sql (41)
- ahref (40)
- js json.parse (59)
- html复选框 (60)
- css 透明 (44)
- css 颜色 (47)
- php replace (41)
- css nth-child (48)
- min-height (40)
- xml schema (44)
- css 最后一个元素 (46)
- location.origin (44)
- table border (49)
- html tr (40)
- video controls (49)