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

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"}];


MYYA
浏览 1191回答 1
1回答

浮云间

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);
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript