【问题标题】:Nativescript Vue: Getting item in array from itemTap in ListViewNativescript Vue:从ListView中的itemTap获取数组中的项目
【发布时间】:2019-12-21 14:53:25
【问题描述】:

我正在尝试在 ListView 中获取 itemTap 上的对象。我希望能够访问对象的nameage。但我不知道如何在onItemTap 函数中做到这一点

数据

listOfItems: [{name: "Tom", age: 55}, {name:"Greg", age: 32}]

模板

<ListView for="item in listOfItems" @itemTap="onItemTap($event)">
  <v-template>
    <Label :text="item.text" />
  </v-template>
</ListView>

方法

onItemTap: function(args) {
  ???
}

【问题讨论】:

  • 有什么更新、新闻吗?

标签: nativescript-vue


【解决方案1】:

docs

Template

<ListView for="item in listOfItems" @itemTap="onItemTap">
  <v-template>
    <!-- Shows the list item label in the default color and style. -->
    <Label :text="item.text" />
  </v-template>
</ListView>

Methods

onItemTap(event) {
  console.log(event.index)
  console.log(event.item)
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-03
    • 1970-01-01
    • 2021-06-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多