あなたはあなたのコードでエクスポートlistViewItemTap
を持っていることを確認することができます。 私は次のことを試してみましたし、[OK]を動作するように思われている:
XML:
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onNavigatingTo">
<ListView items="{{ menu }}" row="1" itemTap="listViewItemTap" >
<ListView.itemTemplate>
<GridLayout columns="auto, *">
<Image src="{{ imageURL }}" row="0" cssClass="icon"/>
<StackLayout col="1">
<Label text="{{ title }}" cssClass="name"/>
<Label text="{{ subtitle }}" cssClass="location"/>
</StackLayout>
</GridLayout>
</ListView.itemTemplate>
</ListView>
</Page>
JS:を探すために
exports.onNavigatingTo = function(args) {
var page = args.object;
page.bindingContext = {
menu:[
{ imageUrl: "", title: "title 1", subtitle: "subtitle 1"},
{ imageUrl: "", title: "title 2", subtitle: "subtitle 2"},
{ imageUrl: "", title: "title 3", subtitle: "subtitle 3"},
{ imageUrl: "", title: "title 4", subtitle: "subtitle 4"},
]
}
}
exports.listViewItemTap = function() {
console.log("Item tapped!");
}
また一つのこと:
- あなたの場合
itemTap
イベントのバインディングを使用しているではありません(XMLの場合と同様にosted) - ページのコードビハインドにイベントハンドラを提供する必要があります。
- がバインディング(
itemTap="{{ listViewItemTap }}"
)を使用してである場合、あなたのbindingContextオブジェクトにイベントハンドラを提供する必要があります。
こんにちは - itemTap関数をエクスポートしたコードビハインドを提供してください。問題システムでは、その関数の簡単な例を掲載しました。 https://github.com/NativeScript/NativeScript/issues/1995 –