【问题标题】:Surrounding NativeScript events in brackets vs not?括号中的 NativeScript 事件与否?
【发布时间】:2020-06-03 18:49:01
【问题描述】:

我尝试了以下代码<Button text="hello?" tap="onTap"></Button>,如教程中所示,但 onTap 函数似乎没有执行。

以下代码确实有效。 <Button text="hello?" (tap)="onTap()"></Button> 我的第二个代码块是否存在常规或其他问题?

【问题讨论】:

  • 你之前有学过任何 Angular 教程吗?

标签: angular nativescript


【解决方案1】:

Angular 事件绑定可以使用括号,例如:

<button (click)="onClick()">Click me!</button>

或者使用前缀-on的规范形式,例如:

<button on-click="onClick()">Click me!</button>

我相信您可能正在查看 NativeScript 核心文档,而不是 Angular 文档。试试看这个:https://docs.nativescript.org/core-concepts/angular-data-binding

【讨论】:

    猜你喜欢
    • 2011-12-28
    • 1970-01-01
    • 2021-07-25
    • 2021-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多