首页 > 解决方案 > Nativescript Angular - 无法在 RadListView 的第一项上触发 itemSelected

问题描述

请帮忙!我无法在 IOS 上单击 radlistview 中的第一项(未触发 onItemSelected),但它在 android 上运行良好。

我的代码:

<GridLayout class="p-x-10">
  <RadListView
    class="users"
    loadOnDemandMode="Auto"
    pullToRefresh="true"
    selectionBehavior="Press"
    [items]="userPaginator.docs"
    (itemSelected)="onItemSelected($event)"
    (loadMoreDataRequested)="onLoadMoreItemsRequested($event)"
    (pullToRefreshInitiated)="onPullToRefreshInitiated($event)"
    >
    <ng-template tkListItemTemplate let-item="item">
      <StackLayout orientation="vertical" class="users__card">
        <Label class="users__card-name" [text]="item.name"></Label>
        <Label class="users__card-username" [text]="item.username"></Label>
        <Label class="users__card-userId" [text]="item.userId"></Label>
        <Label class="users__card-email" [text]="item.email"></Label>
        <Label class="users__card-phone" [text]="item.phone"></Label>
      </StackLayout>
    </ng-template>

  </RadListView>
  <ActivityIndicator
    rowSpan="1"
    [busy]="isPageLoading"
    [visibility]="isPageLoading ? 'visible' : 'collapse'"
    horizontalAlignment="center"></ActivityIndicator>

</GridLayout>

标签: nativescript-angular

解决方案


而不是 OnItemSelected 您可以使用 StackLayout 的点击事件

<StackLayout orientation="vertical" class="users__card" (tap)="onItemSelected($event)">

推荐阅读