【发布时间】:2020-03-18 00:41:25
【问题描述】:
所以我有一个 ListView,它通过一个 onTap 事件循环遍历一个数组对象。 onTap 事件触发它应该触发的功能,但是当我尝试控制台记录 event.index 或 event.item 时,如文档中所列,我的应用程序崩溃说:
"JS ERROR TypeError: undefined is not an object (evalating 'event.index')"
这是我关注的文档:https://nativescript-vue.org/en/docs/elements/components/list-view/
这里是相关的标记:
<ListView for="item in feed" @itemTap="onFeedItemTap()" class="background-gray">
<v-template>
<StackLayout class="feed-item-panel">
<StackLayout orientation="horizontal" style="padding: 5">
<Label class="feed-item" :text="item.Date" row="0" col="0" />
</StackLayout>
<StackLayout orientation="horizontal" style="padding: 5">
<Label class="feed-item bold" :text="'Product: ' + item.Product" fontAttributes="Bold" row="1" col="0" />
</StackLayout>
<StackLayout orientation="horizontal" style="padding: 5">
<Label :class="item.mostRecent" :text="item.info" row="2" col="0" textWrap="true" />
</StackLayout>
</StackLayout>
</v-template>
</ListView>
相关JS函数:
onFeedItemTap(event) {
console.log(event.index); //GIVES ERROR!!
this.$showModal(BBCard);
}
如果我遗漏了什么或者至少指出我正确的方向,请告诉我。但从我所看到的例子来看,这似乎是标准程序。
【问题讨论】:
标签: javascript ios listview nativescript nativescript-vue