当前位置:网站首页>Uncaught typeerror: cannot red properties of undefined (reading 'beforeeach') solution
Uncaught typeerror: cannot red properties of undefined (reading 'beforeeach') solution
2022-07-06 07:01:00 【Wang Zhao has no king】
notes : This is a small problem I encountered when building the project framework in my work , Share the solution
1、 Specific error report : The page is always blank , And report the following error

2、 Cause analysis :
After I think carefully , The discovery is mine router.beforeEach Written in the definition router Before
3、 Solution
Only need to router.beforeEach Write in definition router after , This can solve the above problems .
The following is how to solve the error reporting code , By the way, a logic of login permission function is attached .
4、 Specific code
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
// introduce cookie Tool class
import { getToken } from '../utils/cookie'
// Set up a white list The routes in the white list can be accessed without login
var whiteArr = ['/login','/register','/adminLogin'];
// Login permission function
router.beforeEach((to,from,next) => {
// Current route
var path = to.path;
// Get token
var token = getToken('token');
if (token) { // Yes token Indicates that you are logged in
if (path == '/login') { // If it's the landing page
next('/'); // Go to the home page
}
// If not on the landing page , Send a request to get basic user information , generate menu , Production permission To be done !!!
} else { // No, token No sign in
if (whiteArr.includes(path)) { // The current route is in the white list
next(); // release
} else { // Not on the white list
next('/login'); // Go to login
}
}
next();
})边栏推荐
- ROS learning_ Basics
- librosa音频处理教程
- Practical guidance for interface automation testing (Part I): what preparations should be made for interface automation
- Entity Developer数据库应用程序的开发
- 【服务器数据恢复】IBM服务器raid5两块硬盘离线数据恢复案例
- 接口自动化测试实践指导(上):接口自动化需要做哪些准备工作
- 将ue4程序嵌入qt界面显示
- 【刷题】怎么样才能正确的迎接面试?
- 接口自动化测试框架:Pytest+Allure+Excel
- 呆错图床系统源码图片CDN加速与破解防盗链功能
猜你喜欢

Fedora/rehl installation semanage

18.多级页表与快表

SAP SD发货流程中托盘的管理

Development of entity developer database application
![[server data recovery] case of offline data recovery of two hard disks of IBM server RAID5](/img/c3/7a147151b7338cf38ffbea24e8bafd.jpg)
[server data recovery] case of offline data recovery of two hard disks of IBM server RAID5

Attributeerror: can 't get attribute' sppf 'on < module' models. Common 'from' / home / yolov5 / Models / comm

雲上有AI,讓地球科學研究更省力

漏了监控:Zabbix对Eureka instance状态监控

Huawei equipment configuration ospf-bgp linkage

Hydra common commands
随机推荐
Depth residual network
Brief introduction to the curriculum differences of colleges and universities at different levels of machine human major -ros1/ros2-
Erreur de type résolue avec succès: type de données « catégorie» non sous - jacente
MPLS experiment
作者已死?AI正用艺术征服人类
leetcode35. 搜索插入位置(简单,找插入位置,不同写法)
Day 248/300 thoughts on how graduates find jobs
When my colleague went to the bathroom, I helped my product sister easily complete the BI data product and got a milk tea reward
NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
顶测分享:想转行,这些问题一定要考虑清楚!
UWA pipeline version 2.2.1 update instructions
Interface automation test framework: pytest+allure+excel
Day 246/300 SSH connection prompt "remote host identification has changed!"
The difference between get and post request types
Day 245/300 JS foreach data cannot be updated to the object after multi-layer nesting
Successfully solved typeerror: data type 'category' not understood
Bitcoinwin (BCW): 借贷平台Celsius隐瞒亏损3.5万枚ETH 或资不抵债
Embed UE4 program into QT interface display
Database basics exercise part 2
What does UDP attack mean? UDP attack prevention measures
