JS 数组根据字段或者数组下标过滤数组的数据(fiter)
使用数组的fiter很方便可以根据字段type进行筛选
```javascript
const newData = [
{
details: "尊敬的用户,欢迎您成为xxx平台会员。",
id: 55,
member_id: 19,
source: "系统消息",
status: 1,
title: "注册成功",
type: "重要通知",
},
{
details: "尊敬的用户,请完善信息获得更多功能权限。",
id: 55,
member_id: 19,
source: "系统消息",
status: 1,
title: "注册成功",
type: "重要通知",
},
{
details: "您的订单xxx已经发货!",
id: 55,
member_id: 19,
source: "系统消息",
status: 1,
title: "注册成功",
type: "订单消息",
}
]
//过滤了 type=订单消息的数据
const noticeFiter= newData.filter(item => item.type === '重要通知')
//在上面过滤的基础上,过滤数组下标大于0的数据,相当于只取第一条
const noticeData=noticeFiter.filter((item,index)=> index<=0)
//过滤了 type=重要通知的数据
const orderData = newData.filter(item => item.type === '订单消息')