当前位置:网站首页>nprogress插件 进度条
nprogress插件 进度条
2022-07-05 20:07:00 【阿程_88】
一、安装依赖
npm install nprogress -S
二、引入进度条 NProgress 及对应样式(request.js 文件中)
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
三、使用
// 请求拦截器
instance.interceptors.request.use(
config => {
// 在 request 拦截器中,展示进度条 NProgress.start()
NProgress.start()
if (sessionStorage.getItem('token')) {
config.headers.Authorization = sessionStorage.getItem('token')
}
return config
},
err => {
return Promise.reject(err)
}
)
// 响应拦截器
instance.interceptors.response.use(
res => {
// 在 response 拦截器中,隐藏进度条 NProgress.done()
NProgress.done()
if (res.status === 200) {
return Promise.resolve(res.data)
} else {
return Promise.reject(res)
}
},
err => {
return Promise.reject(err)
}
)
边栏推荐
- Tasks in GStreamer
- selenium 元素信息
- 通配符选择器
- 怎么挑选好的外盘平台,安全正规的?
- JVMRandom不可设置种子|问题追溯|源码追溯
- Build your own website (16)
- Is it safe for Galaxy Securities to open an account online?
- Database logic processing function
- Is it safe for CICC fortune to open an account online?
- [C language] three implementations of quick sorting and optimization details
猜你喜欢

深度學習 卷積神經網絡(CNN)基礎

建立自己的网站(16)

Add data to excel small and medium-sized cases through poi

leetcode刷题:二叉树16(路径总和)

95后阿里P7晒出工资单:狠补了这个,真香...

.Net分布式事務及落地解决方案

CADD课程学习(7)-- 模拟靶点和小分子相互作用 (半柔性对接 AutoDock)

Autumn byte interviewer asked you any questions? In fact, you have stepped on thunder

No matter how busy you are, you can't forget safety

Leetcode brush questions: binary tree 18 (largest binary tree)
随机推荐
Leetcode skimming: binary tree 17 (construct binary tree from middle order and post order traversal sequence)
.Net分布式事务及落地解决方案
Flume series: interceptor filtering data
实操演示:产研团队如何高效构建需求工作流?
Let's talk about threadlocalinsecurerandom
通配符选择器
淺淺的談一下ThreadLocalInsecureRandom
gst-launch的-v参数
Elk distributed log analysis system deployment (Huawei cloud)
Debezium series: modify the source code to support drop foreign key if exists FK
Bitcoinwin (BCW) was invited to attend Hanoi traders fair 2022
Go language learning tutorial (16)
Build your own website (16)
js实现禁止网页缩放(Ctrl+鼠标、+、-缩放有效亲测)
2023年深圳市绿色低碳产业扶持计划申报指南
Jvmrandom cannot set seeds | problem tracing | source code tracing
Leetcode skimming: binary tree 12 (all paths of binary tree)
什么是pyc文件
Force buckle 729 My schedule I
关于BRAM IP复位的优先级