【问题标题】:How to listen directly to a native event on the root element of a component in Nativescript-Vue?如何在 Nativescript-Vue 中直接监听组件根元素上的原生事件?
【发布时间】:2019-08-09 15:28:50
【问题描述】:
  <GridLayout columns="auto, *" rows="*" @tap="openDrawer">
      <Label text="Edit" @tap.native="goToEdit" col="1"></Label>
  </GridLayout>

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

【问题讨论】:

  • 它是 Android 特有的吗?
  • 其实我只在android上测试过

标签: nativescript nativescript-telerik-ui nativescript-vue nativescript-plugin


【解决方案1】:

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

一般来说,在同一区域周围添加多个点击侦听器并不是最佳做法。

【讨论】:

    猜你喜欢
    • 2022-08-16
    • 1970-01-01
    • 2019-06-04
    • 1970-01-01
    • 2020-06-25
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 2021-03-17
    相关资源
    最近更新 更多