【问题标题】:Nativescript ListPicker breaks strings into individual charactersNativescript ListPicker 将字符串分解为单个字符
【发布时间】:2021-07-07 15:13:36
【问题描述】:

我正在尝试使用 Nativescript 的 ListPicker 在我的 ios/android 应用程序中收集数据。我遇到了一个问题,它不是显示每个单独的字符串或数字,而是将所有内容分解为单独的字符。

例如,我想给用户一个左或右选项,但list picker 显示每个字符,而不是左和右两个选项。 Click here for the image of this

我在尝试使用list picker 显示数字列表时遇到了同样的问题,因为它将数字分解为单个字符并在中间添加了数组中的逗号。我试图让用户在这里选择一个高度。 Click here for the image of this

我正在使用native script-angular

代码如下:

HTML 文件:

<ListPicker items="{{ sides }}" ></ListPicker>
 <StackLayout orientation="horizontal">
            <ListPicker items="{{ feet }}" ></ListPicker>
            <ListPicker items="{{ inches }}" ></ListPicker>
 </StackLayout>

TypeScript 文件:

sides = ["Left", "Right"];
feet = [1, 2, 3, 4, 5, 6, 7];
inches = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];

我以前从未使用过 ListPicker,所以我可能会错误地使用它,但根据我的研究,这个执行应该可以正常工作。如果有人有解决办法,我将不胜感激!

【问题讨论】:

    标签: android ios angular nativescript nativescript-angular


    【解决方案1】:

    找到答案 - 在 Html 文件中,而不是像我一样格式化标签,使用这种格式:

    &lt;ListPicker [items]="sides" &gt;&lt;/ListPicker&gt;

    项目上的方括号和你想放入列表选择器中的没有大括号显然都是不同的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-16
      • 1970-01-01
      • 2012-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多