题目
一个数组怎样过滤另一个数组中的值,如下图和代码
一个数组具有悉数数据
另一个数组只具有部份数据
具有悉数数组数组要根据具有部份数据的数组,过滤获得新的数组
代码
具有悉数数据的数组
let allRoutes = [
{
path: '/',
name: 'home',
component: () => import('@/views/Home.vue'),
children: [
{
path: '/role',
name: 'role',
meta: {
tile: '角色'
},
component: () => import('@/views/role/index.vue'),
redirect: '/role/list',
children: [
{
path: 'create',
name: 'roleCreate',
meta: {
tile: '建立角色'
},
component: () => import('@/views/role/create.vue')
},
{
path: 'list',
name: 'roleList',
meta: {
tile: '角色列表'
},
component: () => import('@/views/role/list.vue')
},
{
path: 'update',
name: 'roleUpdate',
meta: {
tile: '修正角色'
},
component: () => import('@/views/role/update.vue')
}
]
},
{
path: '/adminUser',
name: 'adminUser',
meta: {
tile: '管理员'
},
component: () => import('@/views/adminUser/index.vue'),
children: [
{
path: 'create',
name: 'adminUserCreate',
meta: {
tile: '建立管理员'
},
component: () => import('@/views/adminUser/create.vue')
},
{
path: 'list',
name: 'adminUserList',
meta: {
tile: '管理员列表'
},
component: () => import('@/views/adminUser/list.vue')
},
{
path: 'update',
name: 'adminUserUpdate',
meta: {
tile: '修正管理员'
},
component: () => import('@/views/adminUser/update.vue')
}
]
}
]
},
{
path: '*',
name: '404',
component: () => import('@/views/404.vue')
}
]
具有部份数据的数组
比拟悉数数据的数组,没有了name: 'roleCreate',
let someRoutes = [
{
name: 'home',
children: [
{
name: 'role',
children: [{ name: 'roleList' }, { name: 'roleUpdate' }]
},
{
name: 'adminUser',
children: [
{ name: 'adminUserCreate' },
{ name: 'adminUserList' },
{ name: 'adminUserUpdate' }
]
}
]
}
]