代码拉取完成,页面将自动刷新
可以使用 exclude
函数过滤掉不想要的数据
和 filter
方法的区别:
true
的数据将被过滤回调函数参数:
import { exclude } from '@zhengxs/js.tree'
const data = [
{
title: '财务',
children: [{ title: '收入流失' }, { title: '财务设置' }],
},
{
title: '站点设置',
children: [{ title: '菜单维护' }, { title: '角色维护' }],
},
]
const result = exclude(data, (node, index, parents) => {
return node.title.includes('财务') || node.title.includes('角色')
})
// ->
// [
// {
// title: '站点设置',
// children: [{ title: '菜单维护' }],
// },
// ]
默认子级列表的属性名称是 children,可以通过第三个参数修改
import { exclude } from '@zhengxs/js.tree'
const data = [
{
title: '财务',
children: [{ title: '收入流失' }, { title: '财务设置' }],
},
{
title: '站点设置',
children: [{ title: '菜单维护' }, { title: '角色维护' }],
},
]
// 如果不是 children 属性,可以通过第三个参数指定,可选
const result = exclude(
data,
({ title }) => title.includes('财务') || title.includes('角色'),
'items'
)
// ->
// [
// {
// title: '站点设置',
// items: [{ title: '菜单维护' }],
// },
// ]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。