【发布时间】:2019-09-04 02:21:10
【问题描述】:
我有一个 ListView 可以呈现这个:
<ListView v-for="(item, index) in items" height="500">
<v-template v-if="index < items.length - 1">
<GridLayout rows="*, *", columns="220,130,*">
<TextField hint="Project Item" row="0" col="0" />
<TextField hint="Price" row="0" col="1" />
<Button text="X" row="0" col="2" />
</GridLayout>
</v-template>
<!-- render if index reaches last element -->
<v-template v-if="index == items.length - 1">
<GridLayout rows="*, *", columns="220,130,*">
<TextField hint="Project Item" row="0" col="0" />
<TextField hint="Price" row="0" col="1" />
<Button text="index" row="0" col="2" />
</GridLayout>
</v-template>
</ListView>
如果索引到达数组的最后一个元素,则应该呈现第二个 v-template 块。
这是我拥有的数组:
items: [1, 2, 3, 1, 1, 1 ,1 ,1 ,1 ]
页面上呈现的是每个元素的值:TextField 中的1, 2, 3, 1 ...,我的代码中没有定义任何按钮。
如何让条件起作用?
【问题讨论】:
-
你能分享一个可以重现问题的 Playground 示例吗?
标签: nativescript nativescript-vue