首页 > 解决方案 > 带有 Nativescript 的滚动视图中的多个全屏

问题描述

我想知道如何在带有 nativescript 的滚动视图中拥有多个全屏?

在此处输入图像描述

我试过这个:

<Page actionBarHidden="true" class="page">
    <ScrollView orientation="vertical">
        <StackLayout>
            <StackLayout height="100%" backgroundColor="red">
<Label text="Fullscreen 1"></Label>
            </StackLayout>

            <StackLayout height="100%" backgroundColor="blue">
<Label text="Fullscreen 2"></Label>
            </StackLayout>
        </StackLayout>
    </ScrollView>
</Page>

但是堆栈不是全屏的。

标签: nativescriptnativescript-vue

解决方案


我修复了这个:

模板

<Page actionBarHidden="true">
    <ScrollView orientation="vertical">
        <StackLayout>
            <StackLayout :height="screenHeight" backgroundColor="red">
                ...
            </StackLayout>

            <StackLayout :height="screenHeight" backgroundColor="blue">
                ...
            </StackLayout>
        </StackLayout>
    </ScrollView>
</Page>

并添加:

import { screen } from "tns-core-modules/platform";

...
data() {
    return {
        screenHeight: 0
    };
},
...
created() {
    this.screenHeight = screen.mainScreen.heightDIPs
}

推荐阅读