nativescript-vue - Nativescript Vue:从ListView中的itemTap获取数组中的项目
问题描述
我正在尝试在 ListView 中获取 itemTap 上的对象。我希望能够访问对象的name
and age
。但我无法弄清楚如何在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) {
???
}
解决方案
查看文档
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)
}
推荐阅读
- macos - 无法将本地从站连接到 AWS 上的 Jenkins 主站
- powershell - 如何使用
收集关于 2 foreach 的信息 - c# - 如何启动异步任务对象
- python - 词聚类列表列表
- node.js - “ionic cordova build android”命令执行给出错误
- php - 在 SSL 中如何优雅地处理重定向到 http 的 https URL 的 IMG src
- visual-studio-code - 在 VSCode 中将多行选择变成多光标选择
- php - Laravel:更新作曲家文件时获取状态码 255
- javascript - 响应不可分配给类型 Promise
财产终于不见了? - ansible - 将键名提取到列表中