当前位置:网站首页>After login, the upper right corner changes to enter the login status
After login, the upper right corner changes to enter the login status
2022-07-28 04:23:00 【My name is Lili】
adopt currentUser The value of the inside If there is value in it, enter Login to the displayed component If there is no value, the unregistered components will be displayed
First step :
adopt mapState // Get to login login Inside currentUser, Then give to Menu
meanwhile reducer Inside user login The warehouse also adds a field currentUser:initUser(),
If you don't let him in the next time you come in, it's empty stay reducer Inside user login Warehouse write one initUser Method Get... Locally user
const initUser=()=>{
// Get user information locally
const currentUser=getData('currentUser')
if (currentUser) {
return currentUser
}
return null
}
In this way, we can Menu Yes props adopt currentUser The value of the inside If there is value in it, enter Login to the displayed component If there is no value, the unregistered components will be displayed
currentUser It will also read values from the local cache stay reducer login Inside .( adopt initUser Method )
Second point
Login emptying and registration are the same reducer Re value inside
Write the settings
Build a page with exit and update functions
边栏推荐
- C#跨线程刷新前台UI
- Shanghai Telecom released public computing services and signed the action plan of "Joint Innovation Center for intelligent computing applications" with Huawei and other partners
- Domestic high hidden free agent crawler code
- How much does it cost to build a self built server for ark survival evolution?
- H. 265 web player easyplayer realizes webrtc video real-time recording function
- [Niuke] find 1+2+3+... +n
- Use Baidu developer tool 4.0 to build a dedicated applet IDE
- Detailed explanation of pl/sql parameters ("box model")
- Cookies and session
- Machine learning 07: Bayesian learning
猜你喜欢

glusterfs 文件未挂载,权限: r-s

@Requiredargsconstructor annotation

功耗:Leakage Power

XML file usage and parsing

idea启动项目mvn命令终端用不了法将“mvn”项识别为 cmdlet

Experience sharing of automatic test for students with monthly salary of 28K

JDBC usage

Information system project manager (2022) - key content: Project Procurement Management (12)

Do Netease and Baidu have their own tricks for seizing the beach AI learning machine?

网页源代码查看竟然有这么多方法!你都知道吗?
随机推荐
《关于我写自定义cell这件事》
Information system project manager (2022) - key content: information system integrated testing and management, project management maturity model, quantitative project management (21)
月薪28K学员 自动化测试经验分享
ServletContext、request、response
Un7.27: common commands of redis database.
Solana's "deceptive behavior": making mobile phones and opening stores
24-Openwrt dnsmasq
Regression - linear regression
上班摸鱼打卡模拟器微信小程序源码
xml文件使用及解析
2022-7-27 顾宇佳 学习笔记
How much does it cost to build a self built server for ark survival evolution?
重要的 SQL Server 函数 - 日期函数
C#跨线程刷新前台UI
Learn regular expressions (regexp)
UBI read only file system
Information system project manager (2022) - key content: Project Contract Management (13)
Information system project manager (2022) - key content: Information System Security Management (20)
[untitled]
When import is introduced, sometimes there are braces, sometimes there are no braces. How should we understand this?