首页 > 解决方案 > Nativescript 6 - 点击事件未在子元素上触发

问题描述

附加到 StackLayout 的点击事件代码适用于 Android,但不适用于 iOS。

XML:

          <GridLayout id="outmost" row="2">
            <GridLayout rows="*" columns="*, *">
                <StackLayout class="btn btn-filled" col="0" margin="0 7 0 15" tap="login">
                        <Label text="LOG IN" horizontalAlignment="center" verticalAlignment="middle" class="btn-text" />                        
                </StackLayout>
            </GridLayout>    
        </GridLayout>

点击事件不会在 iOS 上触发。如果我将 tap="login" 移动到最顶层的 GridLayout(id=outmost),事件就会触发。在我看来,该事件被 GridLayout#outmost 捕获,而不是向下传播给孩子。

这在我将应用程序迁移到 NS 6 后开始发生。

这是我的 package.json:

{
  "name": "app",
  "nativescript": {
    "id": "com.company.app",
    "tns-ios": {
      "version": "6.0.1"
    },
    "tns-android": {
      "version": "6.0.1"
    }
  },
  "description": "App",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "dependencies": {
    "moment": "^2.24.0",
    "nativescript-appversion": "^1.4.2",
    "nativescript-geolocation": "5.1.0",
    "nativescript-iqkeyboardmanager": "1.3.0",
    "nativescript-loading-indicator": "2.4.0",
    "nativescript-local-notifications": "3.1.0",
    "nativescript-plugin-firebase": "9.0.4",
    "nativescript-theme-core": "~1.0.4",
    "tns-core-modules": "~6.0.0"
  },
  "devDependencies": {
    "nativescript-dev-webpack": "~1.0.0",
    "typescript": "3.4.5"
  },
  "readme": "NativeScript Application",
  "author": ""
}

关于如何解决这个问题的任何想法?

谢谢。

标签: nativescript

解决方案


推荐阅读