Const actions={
GenerateRoutes ({commit}, roles) {
The return of new Promise (resolve=& gt; {
Let accessedRoutes
If (roles. Includes (" admin ")) {
AccessedRoutes=asyncRoutes | | []
Commit (' SET_ROUTES accessedRoutes)
Resolve (accessedRoutes)
} else {
Request ({
Url: 'http://127.0.0.1:5000/api/login/index',
Method: 'get'
}). Then (res=& gt; {
The console. The log (res) data) moreSettings)
Const roleTypes=[
{
Meta: {
Title: 'basic configuration,
Roles: [res. Data. BaseSetting]
},
Children: [{
Meta: {
Title: 'basic configuration,
Roles: [res. Data. BaseSetting]
}
}]
},
{
Meta: {
Title: 'content management,
Roles: [res. Data. MoreSettings]
},
Children:
{
Meta: {
Title: 'lecturer information,
Roles: [res. Data. Head]
}
},
{
Meta: {
Title: 'schedule',
Roles: [res. Data. TimeTable]
}
},
{
Meta: {
Title: 'assistant WeChat',
Roles: [res. Data. QrCode]
}
}
]
}
]
For (let j=0; J & lt; AsyncRoutes. Length; J++) {
For (the let I=0; I & lt; RoleTypes. Length; I++) {
If (roleTypes [I] [' meta] [' title ']===asyncRoutes [j] [' meta] [' title ']) {
AsyncRoutes [j] [' meta] [' roles']=roleTypes [I] [' meta] [' roles']
}
If (' children in asyncRoutes [j]) {
For (let k=0; K & lt; AsyncRoutes [j] [r]. 'children' length; K++) {
For (let e=0; E & lt; RoleTypes [I] [r]. 'children' length; E++) {
If (asyncRoutes [j] [' children '] [k] [' meta] [' title ']===roleTypes [I] [' children '] [e] [' meta] [' title ']) {
AsyncRoutes [j] [' children '] [k] [' meta] [' roles']=roleTypes [I] [' children '] [e] [' meta] [' roles']
The console. The log (' are hard to brush)
The console. The log (asyncRoutes)
AccessedRoutes=filterAsyncRoutes (asyncRoutes, roles)
Commit (' SET_ROUTES accessedRoutes)
Resolve (accessedRoutes)
}
}
}
}
}
}
The console. The log (' end for loop)
//accessedRoutes=filterAsyncRoutes (asyncRoutes, roles)
//commit (' SET_ROUTES 'accessedRoutes)
//resolve (accessedRoutes)
})
The console. The log (' create routing)
AccessedRoutes=filterAsyncRoutes (asyncRoutes, roles)
Commit (' SET_ROUTES accessedRoutes)
Resolve (accessedRoutes)
}
})
}
}
Don't run
The console. The log (' end for loop)
The line
Hope to have bosses can help me to solve! Thank you very much!!