当前位置:网站首页>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 
边栏推荐
- int与string、int与QString互转
- Error reporting on the first day of work (error reporting when Nessus installs WinPcap)
- Blender多镜头(多机位)切换
- Mysql索引
- Alibaba cloud SLS log service
- 2837xd code generation - Supplement (3)
- A model can do two things: image annotation and image reading Q & A. VQA accuracy is close to human level | demo can be played
- UE4夜间打光笔记
- Project practice, redis cluster technology learning (16)
- Image recognition - data augmentation
猜你喜欢

渗透测试的介绍和防范

Kinect DK obtains color RGB images in cv:: mat format (used in openpose)

High level application of SQL statements in MySQL database (II)

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

2837xd code generation - Summary

This monitoring system makes workers tremble: turnover intention and fishing can be monitored. After the dispute, the product page has 404

Alibaba cloud ack introduction

2837xd 代碼生成——StateFlow(4)

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

Bugkuctf-web24 (problem solving ideas and steps)
随机推荐
MySQL transaction
Judging right triangle in C language
2837xd 代码生成——StateFlow(2)
高考那些事
About the college entrance examination
Alibaba / popular JSON parsing open source project fastjson2
Image recognition - Data Cleaning
QT signal slot summary -connect function incorrect usage
2837xd 代码生成——补充(2)
虚幻AI蓝图基础笔记(万字整理)
The latest progress and development trend of 2022 intelligent voice technology
Career planning and development
Project practice, redis cluster technology learning (16)
Error reporting on the first day of work (error reporting when Nessus installs WinPcap)
【虚幻】过场动画笔记
2837xd code generation module learning (2) -- ADC, epwm module, timer0
Introduction et prévention des essais de pénétration
C language: making barrels
In SQL injection, why must the ID of union joint query be equal to 0
2837xd Code Generation - stateflow (4)