gpt4 book ai didi

ios - 组合布局不在 NativeScript 上呈现

转载 作者:行者123 更新时间:2023-11-28 18:28:56 25 4
gpt4 key购买 nike

尝试在 NativeScript View 中输出以下内容

<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="loaded">

<StackLayout>
<Label class="h1 c-grey" text="(re)volution" />

<TextField class="c-bg-grey" id="email" text="{{ email }}" hint="Email Address" keyboardType="email" autocorrect="false" autocapitalizationType="none" />

<TextField secure="true" text="{{ password }}" hint="Password" />

<Button text="Sign in" class="btn btn-primary" tap="signIn" />

</StackLayout>

<GridLayout columns="50, auto, *" rows="50, auto, *" width="210" height="210" style.backgroundColor="lightgray">
<Label text="Label 1" row="0" col="0" backgroundColor="red" />
<Label text="Label 2" row="0" col="1" colSpan="2" backgroundColor="green" />
<Label text="Label 3" row="1" col="0" rowSpan="2" backgroundColor="blue" />
<Label text="Label 4" row="1" col="1" backgroundColor="yellow" />
<Label text="Label 5" row="1" col="2" backgroundColor="orange" />
<Label text="Label 6" row="2" col="1" backgroundColor="pink" />
<Label text="Label 7" row="2" col="2" backgroundColor="purple" />
</GridLayout>

</Page>

模拟器只渲染最后一个元素。无论我尝试实现什么布局,都会发生同样的情况,它总是呈现最后一个布局容器。我在这里错过了什么?我需要声明什么才能在 View 中显示所有布局容器?

最佳答案

页面小部件是 ContentView,这意味着它只接受一个 View 作为 subview 。因此,您需要将 StackLayout 和 GridLayout 包装在另一个布局中,或者移除 StackLayout 并将其放在 GridLayout 中。

最好的解决方案是尽可能少的布局以获得更好的性能。

关于ios - 组合布局不在 NativeScript 上呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40421910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com