为了账号安全,请及时绑定邮箱和手机立即绑定

react怎么筛选数组,返回新的数组

react怎么筛选数组,返回新的数组

MYYA 2019-02-13 18:31:37
var arr =[    {op: "danmaku", text: "大师傅是对方", uid: "1", name: "看看"},    {op: "danmaku", text: "三顿饭地方发", uid: "1", name: "流量"},    {op: "danmaku", text: "徐州持续催促", uid: "2", name: "看看"},    {op: "danmaku", text: "大师傅是对方", uid: "1", name: "看看"},    {op: "danmaku", text: "大是否都是的", uid: "1", name: "看看"}];//有很多项的数据,怎么筛选原数组的数据,新数组只返回text和uid    [{text: "大师傅是对方", uid: "1"},    {text: "三顿饭地方发", uid: "1"},    {text: "徐州持续催促", uid: "2"},    {text: "大师傅是对方", uid: "1"},    {text: "大是否都是的", uid: "1"}];
查看完整描述

1 回答

?
浮云间

TA贡献1829条经验 获得超4个赞

let arr =[{op: "danmaku", text: "大师傅是对方", uid: "1", name: "看看"},

    {op: "danmaku", text: "三顿饭地方发", uid: "1", name: "流量"},

    {op: "danmaku", text: "徐州持续催促", uid: "2", name: "看看"},

    {op: "danmaku", text: "大师傅是对方", uid: "1", name: "看看"},

    {op: "danmaku", text: "大是否都是的", uid: "1", name: "看看"}];

let _arr = arr.map((ele,index)=>{

    return {

        text:ele.text,

        uid:ele.uid

    }

    

})


console.log(_arr);


查看完整回答
反对 回复 2019-02-17
  • 1 回答
  • 0 关注
  • 1190 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信