简单的循环以及从接口获取数组对象的一个字段集合


1.简单的循环字段循环

  if (this.videolist) {
        console.log(111);
        for (let j = 0; j < this.videolist.length; j++) {
          if (this.videolist[j].video) {
            this.showVIdeo = false;
            return;
          } else {
            this.showVIdeo = true;
          }
        }
      } else {
        console.log(222);
        this.showVIdeo = true;
      }

2.使用循环从接口获取数组对象的一个字段集合

   let list= [];
          for (let j = 0; j < res.data.result.xxoptization.length; j++) {
            if(res.data.result.xxoptization[j].video){
              let temporaryItem = {};
              temporaryItem.video = res.data.result.xxoptization[j].video;
              temporaryItem.videoimg = res.data.result.xxoptization[j].videoimg;
              temporaryItem.videoname = res.data.result.xxoptization[j].videoname;
              temporaryItem.title = res.data.result.xxoptization[j].title;
              list.push(temporaryItem);
            }
          }
          this.videolist.push(...list);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM