Ionic framework 如何使用php在ionic3中显示youtube json数据

Ionic framework 如何使用php在ionic3中显示youtube json数据,ionic-framework,ionic3,Ionic Framework,Ionic3,我获得了youtube json数据并将其保存在http://localhost/jsonyoutube.php 现在我想在ionic视图页面(即home.html)中显示json数据 当我尝试时,我得到了错误:error错误:尝试区分“[object]”时出错。只允许使用数组和iterables 但当我在控制台中尝试时,效果很好。我无法在查看页面中显示它 这里我分享我的代码 home.ts load() : void { this.http .get('http://

我获得了youtube json数据并将其保存在
http://localhost/jsonyoutube.php

现在我想在ionic视图页面(即home.html)中显示json数据

当我尝试时,我得到了错误:
error错误:尝试区分“[object]”时出错。只允许使用数组和iterables

但当我在控制台中尝试时,效果很好。我无法在查看页面中显示它

这里我分享我的代码

home.ts

     load() : void
    {
  this.http
  .get('http://localhost/jsonyoutube.php')
  .subscribe((data : any) =>
   {
     //console.dir(data.items["0"].snippet.thumbnails.default.url);
     console.dir(data);
     this.items = data;
     //console.dir(this.items);
   },
  (error : any) =>
  {
     console.dir(error);
  });
  }
home.html

  <ion-content padding style="background-color: #251D32 !important;">
  <ion-grid >
  <ion-row>
   <ion-col col-6 col-md-4 col-xl-3 *ngFor="let item of items">
    <ion-card class="video-container">
     <iframe src="https://www.youtube.com/embed/{{item.id.videoId}}" 
    frameborder="0" width="100%" height="315" allowfullscreen></iframe>
        </ion-card>
  </ion-col>  
  </ion-row>
  </ion-grid>  
  </ion-content>


您必须将数据转换为数组。使用maybe-map和与ngformable-duplicate的迭代可能重复的可能重复怎么做?@Cristian@Vignesh-Ram我不知道如何制作你的项目,但基本上创建并清空数组,并将data.items推送到其中。然后在html中使用ngFor进行迭代