問(wèn)題簡(jiǎn)介:
- 登陸后,后臺(tái)返回有路由列表。本地寫好的有路由列表。通過(guò)兩者對(duì)比,將相同的路由動(dòng)態(tài)加載到路由中
- 通過(guò)for map 等進(jìn)行對(duì)比。進(jìn)入死循環(huán)
// 返回的路由列表 截取一個(gè)
{
id: 2,
path: '/Article',
name: '/Article',
meta: {
title: '文章管理',
icon: '_Article_management'
},
component: Main,
children: [
{
id: 21,
pid: 2,
path: 'articletype',
name: 'articletype',
meta: {
title: '文章類型列表',
},
component: () => import('@/view/Article/articletype/index.vue')
},
{
id: 22,
pid: 2,
path: 'article',
name: 'article',
meta: {
title: '文章列表',
},
component: () => import('@/view/Article/article/index.vue')
},
]
}
// 本地路由表
{
id: 2,
path: '/Article',
name: '/Article',
meta: {
title: '文章管理',
icon: '_Article_management'
},
component: Main,
children: [
{
id: 21,
pid: 2,
path: 'articletype',
name: 'articletype',
meta: {
title: '文章類型列表',
},
component: () => import('@/view/Article/articletype/index.vue')
},
{
id: 22,
pid: 2,
path: 'article',
name: 'article',
meta: {
title: '文章列表',
},
component: () => import('@/view/Article/article/index.vue')
},
]
}
{
id: 3,
path: '/Ordering',
name: '/Ordering',
meta: {
title: '訂貨會(huì)管理',
icon: '_Ordering'
},
component: Main,
children: [
{
id: 31,
pid: 3,
path: 'web-meeting',
name: 'web-meeting',
meta: {
title: '主題列表'
},
component: () => import('@/view/Ordering/web-meeting/index.vue')
},
{
id: 32,
pid: 3,
path: 'web-meetingStatus',
name: 'web-meetingStatus',
meta: {
title: '商品上線'
},
component: () => import('@/view/Ordering/web-meetingStatus/index.vue')
},
{
id: 33,
pid: 3,
path: 'web-meetingCart',
name: 'web-meetingCart',
meta: {
title: '購(gòu)物車管理'
},
component: () => import('@/view/Ordering/web-meetingCart/index.vue')
}
]
},
- 兩者是相同的。 通過(guò)id 進(jìn)行判斷(這樣是錯(cuò)誤的。因?yàn)閕d 會(huì)變動(dòng)。但是沒(méi)什么問(wèn)題。改成其他的也可以)
如何對(duì)比兩者,避免死循環(huán)
死循環(huán)產(chǎn)生(當(dāng)本地多寫一組路由數(shù)據(jù),就會(huì)產(chǎn)生) 現(xiàn)代碼本地比返回的數(shù)據(jù)多一組。產(chǎn)生死循環(huán) 求解決