如何直接在Nativescript-Vue中的组件的根元素上侦听本机事件?

问题描述 投票:0回答:1
  <GridLayout columns="auto, *" rows="*" @tap="openDrawer">
      <Label text="Edit" @tap.native="goToEdit" col="1"></Label>
  </GridLayout>

通常,在vue.js中,我们使用.native后缀来调用本机子组件事件。我在native-script-vue中遇到“.native”问题。如果我使用没有“.native”后缀的事件,则父和子事件都会触发。我想只触发子元素。

nativescript nativescript-telerik-ui nativescript-vue nativescript-plugin
1个回答
0
投票

本机后缀(.native)被指定用于自定义组件,以便跟踪根元素的事件。如果你将它与上面的Label这样的实际元素一起使用,它将无声地失败。它永远不会触发事件。

通常,在同一区域添加多个tap监听器并非最佳做法。

© www.soinside.com 2019 - 2024. All rights reserved.