将多个对象合并成一个数组的方法

   console.log(res);
   console.log(res.data.activities);//这是多个对象
        var activityList = [];
        const activityData = res.data.activities;
        for (const key in activityData) {
          if (activityData[key]) {
            activityList = activityList.concat(activityData[key]);
          }
        }
   console.log(activityList);//合并后的数组

 

posted @ 2020-11-19 14:14  Running°つ  阅读(2247)  评论(0编辑  收藏  举报