Nativescript 如何使用ngFor循环将StackLayout制作成可滚动列表?
首先使用Nativescript 如何使用ngFor循环将StackLayout制作成可滚动列表?,nativescript,angular2-nativescript,Nativescript,Angular2 Nativescript,首先使用StackLayout包装整个代码,然后使用ScrollView包装整个代码 <ScrollView> <ListView [items]="videos$ | async" class="list-group"> <ng-template let-item="item"> <GridLayout class="list-group-item"> <Image [src]="item.sn
StackLayout
包装整个代码,然后使用ScrollView
包装整个代码
<ScrollView>
<ListView [items]="videos$ | async" class="list-group">
<ng-template let-item="item">
<GridLayout class="list-group-item">
<Image [src]="item.snippet.thumbnails.high.url"></Image>
<Label [text]="item.snippet.channelTitle" ></Label>
<Label [text]="item.snippet.title">></Label>
</GridLayout>
</ng-template>
</ListView>
</ScrollView>
>
首先使用StackLayout
包装整个代码,然后使用ScrollView
进行包装
<ScrollView>
<ListView [items]="videos$ | async" class="list-group">
<ng-template let-item="item">
<GridLayout class="list-group-item">
<Image [src]="item.snippet.thumbnails.high.url"></Image>
<Label [text]="item.snippet.channelTitle" ></Label>
<Label [text]="item.snippet.title">></Label>
</GridLayout>
</ng-template>
</ListView>
</ScrollView>
>
<ScrollView>
<StackLayout>
<StackLayout width="100%" *ngFor="let item of (videos$ | async)">
<CardView class="studentCard" margin="2" elevation="10" radius="1">
<GridLayout rows="auto, auto, auto" columns="auto, auto, *">
<Image [src]="item.snippet.thumbnails.high.url" stretch="aspectFill" colSpan="3" row="0"></Image>
<Label [text]="item.snippet.channelTitle" textWrap="true" row="2" colSpan="1" ></Label>
<Label [text]="item.snippet.title" textWrap="true" row="2" col="1" colSpan="2" >></Label>
</GridLayout>
</CardView>
</StackLayout>
</StackLayout>
</ScrollView>