当前位置:网站首页>How to achieve the top progress bar effect in background management projects
How to achieve the top progress bar effect in background management projects
2022-07-02 10:09:00 【Capricorn**】
First installation
npm i nprogress
# perhaps
yarn add nprogress
Besides the function , The progress bar also has styles , The first thing you need to do is main.js Introducing style
import 'nprogress/nprogress.css'
stay router/index.js in , Introduce the module
import nprogress from 'nprogress'
In the global front guard Start the route before jumping nprogress
router.beforeEach((to,from,next)=>{
// Turn on before route jump
nprogress.start()
// As long as the access is not login /login Jump to /login
if(to.path === '/login'){
next()
}else{
// Get localstorage Medium token
const token = localStorage.getItem('token')
if(token){
// If it's not login But I have logged in Then jump normally
next()
}else{
next('/login')
}
}
})
After the route jump ends ( Route post hook ) call done Method end
// Route post hook
router.afterEach(()=>{
// After the route jump is completed The progress bar ends
nprogress.done()
})
Such as the following effect 
边栏推荐
- QT信号槽总结-connect函数错误用法
- 逆变器simulink模型——处理器在环测试(PIL)
- Tools used for Yolo object recognition and data generation
- 虚幻AI蓝图基础笔记(万字整理)
- Project practice, redis cluster technology learning (VII)
- Tee command usage example
- 2837xd 代码生成——StateFlow(4)
- [Yu Yue education] University Physics (Electromagnetics) reference materials of Taizhou College of science and technology, Nanjing University of Technology
- Project practice, redis cluster technology learning (11)
- What is call / cc- What is call/cc?
猜你喜欢

渗透测试的介绍和防范

2837xd code generation - Summary

Mysql索引

Alibaba cloud ack introduction

Share a blog (water blog)

Ue5 - ai Pursuit (Blueprint, Behavior tree)

Image recognition - Data Cleaning

Personal experience & blog status
![[illusory] weapon slot: pick up weapons](/img/a7/1e395fc9cdfd0359e7ae4d2313290d.png)
[illusory] weapon slot: pick up weapons

Mixed development of uni app -- Taking wechat applet as an example
随机推荐
Personal experience & blog status
Web security and defense
TD conducts functional simulation with Modelsim
2837xd code generation module learning (1) -- GPIO module
Database -- acid of transaction -- introduction / explanation
Introduction et prévention des essais de pénétration
Junit4运行mvn test 测试套件升级方案
cmake的命令-官方文档
Error reporting on the first day of work (error reporting when Nessus installs WinPcap)
PI control of grid connected inverter (grid connected mode)
Ue5 - ai Pursuit (Blueprint, Behavior tree)
2837xd Code Generation - Supplement (1)
Junit5 支持suite的方法
Eslint reports an error
Matlab生成dsp程序——官方例程学习(6)
MySQL transaction
2837xd code generation - stateflow (3)
int与string、int与QString互转
Save video opencv:: videowriter
Vs+qt set application icon