当前位置:网站首页>UMI route interception (simple and rough)
UMI route interception (simple and rough)
2022-07-03 03:15:00 【Recall @y】
One 、 Business scenario :
Recently in use umi Development , Some pits were encountered when rendering navigation routes , For everyone to meet the same problem as me later , Let me share with you
Two 、 Solution :
First add a high-level component , At the same level as all components , Add configuration where you want to configure the route wrappers: [‘@/wrappers/auth’], I'm afraid we don't understand , Here is a picture .
3、 ... and 、 Specific implementation steps
1、 stay src Under the directory of , and page At the same level , Create a new one wrappers Folder ( The name is fixed ), Create a new Auth.tsx file ,
2、 Write the following contents in the file :
import {Redirect} from 'umi'
export default function Auth(props:any) {
// Get local cache localStorage Value
const isLogin = localStorage.getItem('role')
// If this value exists, it will return to the normal content
if(isLogin){
return (
<div>
{props.children}
</div>
);
}else {
// If this value exists, redirect to the login page
console.log(' Skip login ')
return ( <Redirect to='/login' />)
}
}
3、 Add wrappers: [‘@/wrappers/auth’], What needs to be intercepted must be added , Pictured 
Four 、 Effect display

This is the end of today's sharing , Welcome friends to communicate together
边栏推荐
- Edit and preview in the back pipe to get the value writing method of the form
- Unity3d RPG implementation (medium)
- [algebraic structure] group (definition of group | basic properties of group | proof method of group | commutative group)
- Reset or clear NET MemoryStream - Reset or Clear . NET MemoryStream
- Destroy the session and empty the specified attributes
- 模糊查詢時報錯Parameter index out of range (1 > number of parameters, which is 0)
- 左连接,内连接
- C # general interface call
- 监听对象中值变化及访问
- 程序员新人上午使用 isXxx 形式定义布尔类型,下午就被劝退?
猜你喜欢

MySql實戰45講【SQL查詢和更新執行流程】

Section 26 detailed explanation and demonstration of IPSec virtual private network configuration experiment - simulation experiment based on packettracer8.0

Vs 2019 configure tensorrt to generate engine
![[shutter] monitor the transparency gradient of the scrolling action control component (remove the blank of the top status bar | frame layout component | transparency component | monitor the scrolling](/img/c3/b9a614001f80345a5c1cb3c68ab27c.jpg)
[shutter] monitor the transparency gradient of the scrolling action control component (remove the blank of the top status bar | frame layout component | transparency component | monitor the scrolling

Limit of one question per day

Summary of determinant knowledge points in Chapter 1 of Linear Algebra (Jeff's self perception)

Limit of one question per day

Pytoch configuration

MySql实战45讲【行锁】

左连接,内连接
随机推荐
Summary of determinant knowledge points in Chapter 1 of Linear Algebra (Jeff's self perception)
I2C 子系统(四):I2C debug
Anhui University | small target tracking: large-scale data sets and baselines
I2C 子系統(四):I2C debug
Limit of one question per day
PAT乙级“1104 天长地久”DFS优化思路
The base value is too large (the error is marked as "08") [duplicate] - value too great for base (error token is'08') [duplicate]
VS 2019 配置tensorRT生成engine
Section 26 detailed explanation and demonstration of IPSec virtual private network configuration experiment - simulation experiment based on packettracer8.0
Do you really understand relays?
How to make backgroundworker return an object
Idea format code idea set shortcut key format code
VS 2019配置tensorRT
解决高並發下System.currentTimeMillis卡頓
使用InputFilter限制EditText时踩坑及解决方案
Notifydatasetchanged not applicable to recyclerview - notifydatasetchanged not working on recyclerview
Pytorch配置
力扣------网格中的最小路径代价
ComponentScan和ComponentScans的区别
Are there any recommended term life insurance products? I want to buy a term life insurance.