NativeScript在ListView中的ItemTap事件不工作

NativeScript在ListView中的ItemTap事件不工作,nativescript,Nativescript,在ListView中,ItemTap事件不起作用 <ListView items="{{ menu }}" row="1" itemTap="listViewItemTap" > <ListView.itemTemplate> <GridLayout columns="auto, *"> <Image src="{{ imageURL }}" row="0" cssClass="icon"/>

ListView
中,
ItemTap
事件不起作用

<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>

您能否确保在您的代码中导出了
列表视图项点击
。 我尝试了以下方法,似乎效果不错:

XML:

还有一件事需要注意:

  • 如果没有为
    itemTap
    事件使用绑定(如您发布的XML中所示),则应该在页面的代码后面提供事件处理程序
  • 如果正在使用绑定(
    itemTap=“{{{listViewItemTap}}}”
    ),则应在bindingContext对象中提供事件处理程序

您能否确保在您的代码中导出了
列表视图项tap
。 我尝试了以下方法,似乎效果不错:

XML:

还有一件事需要注意:

  • 如果没有为
    itemTap
    事件使用绑定(如您发布的XML中所示),则应该在页面的代码后面提供事件处理程序
  • 如果正在使用绑定(
    itemTap=“{{{listViewItemTap}}}”
    ),则应在bindingContext对象中提供事件处理程序

您好-请在导出itemTap功能的地方提供您的代码。在发布系统中,我发布了该功能的一个简单示例。您好-请在导出itemTap函数的地方提供您的代码。在发布系统中,我发布了该功能的一个简单示例。谢谢此示例正在运行。在我想记住的一件事上,我已经在我们的项目中集成了pulltorefresh插件,所以我想检查它为什么不工作?谢谢。此示例正在运行。我想记住的是,我已经在我们的项目中集成了pulltorefresh插件,所以我想检查它为什么不工作?。
<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>
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!");
}