从一个数组对象中过略出另一个数组含有的项

      const col = ['JiGouName','SchoolName']           
        const column= [
                        {title:'机构',dataIndex:'JiGouName'},
                        {title:'校区',dataIndex:'SchoolName'},
                        {title:'课程类别',dataIndex:'LessonClassName'},
                        {title:'课程',dataIndex:'LessonName'},
                        {title:'班级',dataIndex:'ClassName'},
                        {title:'学员',dataIndex:'StuName'},
                        {title:'交易类型',dataIndex:'TranType'},
                        {title:'订单类型',dataIndex:'OrderType'},
                        {title:'经办员',dataIndex:'JingBanYuan'},
                        {title:'销售员',dataIndex:'XiaoShouYuan'},
                    ]
        
        let tempArr=[];
        column.filter((co,i)=>{
                  let temp=col.indexOf(co.dataIndex);
                  if(temp>=0){
                      tempArr.push(co);
                        }
                  })   
        console.log('1', tempArr)   // 0:{title: "机构", dataIndex: "JiGouName"}
                                    // 1:{title: "校区", dataIndex: "SchoolName"}        

猜你喜欢

转载自www.cnblogs.com/aloehui/p/9141852.html