簡單的循環以及從接口獲取數組對象的一個字段集合


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