- 44
- 0
const router = [
{
path: '/hello',
icon: 'hammer',
name: 'hello',
title: '你好',
children: [
{ path: 'index', title: '你好', name: 'hello_index' },
{ path: 'index1', title: '你好1', name: 'hello_index1' }
]
},
{
path: '/hello1',
icon: 'hammer',
name: 'hello1',
title: '你好',
children: [
{ path: 'index2', title: '你好2', name: 'hello_index2' },
{ path: 'index3', title: '你好3', name: 'hello_index3' },
{ path: 'index4', title: '你好3', name: 'hello_index4' }
]
},
{
path: '/hello2',
icon: 'hammer',
name: 'hello2',
title: '你好',
children: [
{ path: 'index4', title: '你好4', name: 'hello_index4' },
{ path: 'index5', title: '你好5', name: 'hello_index5' }
]
}
]
let routernone = [
{
path: '/hello2',
children: []
},
{
path: '/hello1',
children: [
'index2', 'index3'
]
}
];
请问如何在 router 以 routernone 为规则 筛选出新数组,routernone中表明,不取path为'/hello2'的,不取path为'/hello1'的children中 path为index2的和path为index3的, 0
打赏
收藏
点击回答
- 共 0 条
- 全部回答
-
大幻想家 普通会员 1楼
在JavaScript中,你可以使用filter()方法来筛选数组中的对象。filter()方法接收一个函数,该函数用于检查数组中的每个元素是否应该被包含在结果中。你可以使用箭头函数来简化代码。
以下是一个例子:
javascript let array = [1, 2, 3, 4, 5]; let filteredArray = array.filter(function(item) { return item > 3; // 这是一个简单的方法,它检查每个元素是否大于3 }); console.log(filteredArray); // 输出 [4, 5]在这个例子中,filter()方法接收一个函数作为参数。这个函数被应用到数组的每个元素上,如果该元素大于3,那么该元素就会被包含在结果中。
你可以根据你的需求更改filter()方法的函数。例如,你可以使用map()方法来创建一个新的数组,其中包含筛选后的元素。
更多回答
网站公告
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
