当前位置:网站首页>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 
边栏推荐
- 渗透测试的介绍和防范
- C language: making barrels
- Introduction to go language
- Minimum number of C language
- PI control of grid connected inverter (grid connected mode)
- JDBC review
- C language programming problems
- [Yu Yue education] University Physics (Electromagnetics) reference materials of Taizhou College of science and technology, Nanjing University of Technology
- 2837xd代码生成模块学习(4)——idle_task、Simulink Coder
- Mysql索引
猜你喜欢

2837xd 代码生成——补充(3)

三相逆变器离网控制——PR控制

Ue5 - ai Pursuit (Blueprint, Behavior tree)

2837xd 代碼生成——補充(1)

Junit5 supports suite methods

Off grid control of three-phase inverter - PR control

PI control of grid connected inverter (grid connected mode)

2837xd代码生成模块学习(1)——GPIO模块

In SQL injection, why must the ID of union joint query be equal to 0

tinyxml2 读取和修改文件
随机推荐
2837xd code generation module learning (1) -- GPIO module
阿里云ack介绍
Ckeditor 4.10.1 upload pictures to prompt "incorrect server response" problem solution
C language: making barrels
职业规划和发展
TD conducts functional simulation with Modelsim
Alibaba cloud Prometheus monitoring service
Alibaba cloud ack introduction
About the college entrance examination
2837xd 代码生成——StateFlow(4)
【UE5】AI随机漫游蓝图两种实现方法(角色蓝图、行为树)
Database -- acid of transaction -- introduction / explanation
Record the interesting process of using Xray for the first time
2837xd 代碼生成——補充(1)
How to handle error logic gracefully
保存视频 opencv::VideoWriter
Project practice, redis cluster technology learning (16)
Junit4 runs MVN test test suite upgrade scheme
Project practice, redis cluster technology learning (10)
Alibaba / popular JSON parsing open source project fastjson2