当前位置:网站首页>Application of global route guard
Application of global route guard
2022-06-25 10:54:00 【Stranger & love sorrow】
Front routing guard router.beforeEach
Determine whether the page needs to log in
1 Set... In the route meta isToken The page used to determine whether you need to log in to enter
{
path: '/login',
name: 'login',
component: () => import('../views/Login.vue'),
meta: {
title: ' Sign in ',
isToken: false
},
},
2 The front guard judges
router.beforeEach((to, from, next) => {
// obtain token
let token = localStorage.getItem('token')
if (token && token != 'null') { // Yes token release
next()
} else {
// Determine whether the page needs to be logged in
if (to.meta.isToken) { // by true Indicates a page that can only be accessed after login
Toast(' Please log in first ');
// Return to login page
next('/login')
} else {
next()
}
}
})
Post route hook router.afterEach
Set dynamic title
1 Pictured above , Set up meta Inside title attribute
meta: {
title: ' Sign in ',
isToken: false
},
2 Post route guard settings
router.afterEach((to, from, next) => {
document.getElementById('titleId').innerHTML = to.meta.title
})
Global analysis guard router.beforeResolve
Before the navigation is confirmed , At the same time, after guard and asynchronous routing components in all components are resolved , Parse guard is called
边栏推荐
- Is it safe for Guosen Securities to open a securities account
- XSS attack
- Tutorial on installing SSL certificates in Microsoft Exchange Server 2007
- 【历史上的今天】6 月 24 日:网易成立;首届消费电子展召开;世界上第一次网络直播
- [today in history] June 24: Netease was established; The first consumer electronics exhibition was held; The first webcast in the world
- Checking whether the double value is an integer - Swift - checking if a double value is an integer - swift
- Daily 3 questions (3) - check whether integers and their multiples exist
- 2022-06-24:golang选择题,以下golang代码输出什么?A:1;B:3;C:4;D:编译失败。 package main import ( “fmt“ ) func mai
- OODA工作法
- Comparison and evaluation of digicert and globalsign single domain ov SSL certificates
猜你喜欢
Deep understanding of JVM - JVM memory model
Floating window --- create an activity floating window (can be dragged)
The title of my composition is - "my district head father"
网络协议学习---LLDP协议学习
Dell technology performs the "fast" formula and plays ci/cd
MCU development -- face recognition application based on esp32-cam
戴尔科技演绎“快”字诀,玩转CI/CD
After reading this article, I will teach you to play with the penetration test target vulnhub - drivetingblues-7
【观察】ObjectScale:重新定义下一代对象存储,戴尔科技的重构与创新
[file containing vulnerability-03] six ways to exploit file containing vulnerabilities
随机推荐
Your driver settings have been set to force 4x antialiasing in OpenGL applications
[paper reading | deep reading] drne:deep recursive network embedding with regular equivalence
Oracle query comes with JDK version
Checking whether the double value is an integer - Swift - checking if a double value is an integer - swift
每日3題(3)-檢查整數及其兩倍數是否存在
A random number generator
MCU development -- face recognition application based on esp32-cam
[today in history] June 24: Netease was established; The first consumer electronics exhibition was held; The first webcast in the world
Garbage collection mechanism
COSCon'22 讲师征集令
Task03 probability theory
我希望按照我的思路盡可能將canvas基礎講明白
Floating window --- create an activity floating window (can be dragged)
The real difference between i++ and ++i
Floating window --- create a system floating window (can be dragged)
Houdini graphic notes: could not create OpenCL device of type (houdini_ocl_devicetype) problem solving
Bitmap is converted into drawable and displayed on the screen
【动态规划】—— 数字三角形
Comparison and evaluation of digicert and globalsign single domain ov SSL certificates
Google Earth Engine(GEE)——evaluate实现一键批量下载研究区内的所有单张影像(上海市部分区域)