首页 > 解决方案 > NativeScript JS:缺少带有 resourceID 的图像 - 远程图像 API

问题描述

我正在用 angular 用 nativescript 做一个小应用程序,我用 service.ts 使用测试 api

getItems(){
    return this.http.get('https://apiexample.com/url');
  }

它返回带有几张图像的 json,但是当我使用这个示例并直接输入 url

<image
  src="https://art.nativescript.org/logo/export/NativeScript_Logo_Blue_White.png"
  stretch="aspectFill"
>
</image>

图片显示

但是当我这样使用时

<GridLayout>
  
  <ListView [items]="items">
    <ng-template let-item="item">
      <StackLayout>
        <image
  [src]="item.img_src"
  stretch="aspectFill"
  loadMode="async"
>
</image>
         <Label [text]="item.id"></Label>      
      </StackLayout>
    </ng-template>
  </ListView>
</GridLayout>

如果我这样写代码,它就不会再显示任何东西了。但在控制台上它告诉我JS: Missing Image with resourceID 有 什么想法吗?泰

在此处输入图像描述

标签: androidangularnativescript

解决方案


推荐阅读