首页 > 解决方案 > Nativescript 水平滚动效果很好,但不适用于项目模板

问题描述

我正在尝试使用动态列表中的项目模板创建一组水平滚动的项目。以下手动代码按预期工作 - 水平滚动的“票证”列表:

<ScrollView orientation="horizontal">
  <StackLayout orientation="horizontal" class="scroll-menu">
        <StackLayout class="ticket-panel">
          <Label text="A ticket" />
        </StackLayout>
        <StackLayout class="ticket-panel">
          <Label text="A ticket" />
        </StackLayout>
        <StackLayout class="ticket-panel">
          <Label text="A ticket" />
        </StackLayout>
        <StackLayout class="ticket-panel">
           <Label text="A ticket" />
        </StackLayout>
  </StackLayout>
</ScrollView>

但以下没有。它垂直滚动。itemTemplate 在列表中插入的 xml 是否比我使用 itemTemplate 时更多?

<ScrollView orientation="horizontal">
  <StackLayout orientation="horizontal" class="scroll-menu">
    <ListView items="{{ ticketList }}">
      <ListView.itemTemplate>
        <StackLayout class="ticket-panel">
         <Label text="A ticket" />
        </StackLayout>
      </ListView.itemTemplate>
    </ListView>
  </StackLayout>
</ScrollView>

标签: javascriptnativescripthorizontalscrollview

解决方案


推荐阅读