Svelte Native ListView - 水平

问题描述 投票:0回答:1

我尝试在 Svelte Native 上构建我的第一个应用程序。我为平板电脑开发了这个。 标准ListView仅支持垂直堆叠。 我需要这个来水平放置。

此部分仅适用于垂直:

<listView items="{listOfItems}" on:itemTap="{onItemTap}">
    <Template let:item>
        <!-- Shows the list item label in the default color and style. -->
        <label text="{item}" />
    </Template>
</listView>

<script>
    import { Template } from 'svelte-native/components'
    let listOfItems = ['one', 'two', 'three']
</script>

我也尝试这个: 我遇到的问题是没有显示任何内容。

{#each one as ones}
    <button on:tap={addToList(ones)} text="{ones.name}" class="prod-btn" />
{/each}

所以我需要帮助在水平视图中显示对象列表。

nativescript svelte
1个回答
0
投票

所以目前还不太可能做到这一点。水平滚动也是如此,因为 svelte native 是一个新的社区项目。我建议只使用 stackLayout。这是一个带有上下文的示例:

我们想要一个简单的 stackLayout:

<stackLayout orientation="horizontal" width="100%" height="150" background="blue">
   <label text="item 1" width="60" height="100%" marginRight="10" background="orange">
   <label text="item 2" width="60" height="100%" marginRight="10" background="green">
</stackLayout>

我希望它对你有用,如果它不总是尝试检查精简的本机 API 文档并尝试在 REPL(基本上是在线编辑器)中工作/实验来测试东西,这样你就不会意外地破坏你的应用程序。

  1. 文档:https://svelte-native.technology/docs
  2. 回复: https://svelte-native.technology/repl?version=3.58.0&example=hello-world
© www.soinside.com 2019 - 2024. All rights reserved.