使用中继器时将方向更改为垂直

时间:2018-07-10 14:23:38

标签: nativescript repeater

我正在NS中创建水平滚动。使用以下代码时,它可以按预期工作。

<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onPageLoad" class="page">
<StackLayout>
    <!-- This is where the magic happens -->
    <ScrollView orientation="horizontal">
        <StackLayout orientation="horizontal" class="scroll-menu">
            <StackLayout class="scroll-pane">
                <Button text="Button" />                  
            </StackLayout>
            <StackLayout class="scroll-pane">
                <Button text="Button" />                  
            </StackLayout>
            <StackLayout class="scroll-pane">
                <Button text="Button" />                  
            </StackLayout>
            <StackLayout class="scroll-pane">
                <Button text="Button" />                  
            </StackLayout>
         </StackLayout>
    </ScrollView>

</StackLayout>

水平滚动:

enter image description here

但是,一旦我使用中继器,它就会变为“垂直”方向,而不是滚动。

<Page  xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onPageLoad" class="page">
<StackLayout>
    <!-- This is where the magic happens -->
    <ScrollView orientation="horizontal">
        <StackLayout orientation="horizontal" class="scroll-menu">
        <Repeater items="{{ categories }}"  > 
            <Repeater.itemTemplate>
                <StackLayout class="scroll-pane" >
                    <Label text="{{name}}" />
                </StackLayout>                
            </Repeater.itemTemplate>
        </Repeater>
         </StackLayout>
    </ScrollView>

</StackLayout>

使用中继器时更改为垂直:

enter image description here

代码有什么问题?

0 个答案:

没有答案