【问题标题】:Ionic 4 Click event离子 4 点击事件
【发布时间】:2020-02-26 02:45:11
【问题描述】:

您好,我开始学习 Ionic 4。目前我在 packages.json 中的版本是

      "@angular/animations": "~7.0.0",
      "@angular/common": "^7.2.2",
      "@angular/core": "^7.2.2",
      "@angular/platform-browser": "^7.2.2",
      "@angular/platform-browser-dynamic": "^7.2.2",
      "@angular/router": "^7.2.2",
      "@ionic-native/core": "^5.0.0",
      "@ionic-native/splash-screen": "^5.0.0",
      "@ionic-native/status-bar": "^5.0.0",
      "@ionic/angular": "^4.0.0"

我正在尝试将按钮用作

<button ion-button (click)="test()">Click Me! </button>

问题是点击事件没有绑定。我在这里错过了什么?

【问题讨论】:

  • “不绑定”是什么意思?你的测试功能里面有什么?你如何测试你的代码?
  • 你能分享你的打字稿文件吗?
  • 在我的测试函数中只有一个 console.log('string') 行!我找到了 Ionic 4 不支持按钮标签的答案。检查 +Tomas 的答案

标签: ionic-framework ionic4


【解决方案1】:

Ionic 4 不再使用&lt;button&gt; 标签,而是使用&lt;ion-button&gt;

<!-- Default -->
<ion-button>Default</ion-button>

看看这里:https://beta.ionicframework.com/docs/api/button

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-03
    • 1970-01-01
    • 1970-01-01
    • 2019-01-02
    • 2019-06-21
    • 1970-01-01
    • 2018-07-13
    相关资源
    最近更新 更多