首页 > 解决方案 > 卡片上的离子长按事件

问题描述

如何在 Ionic 中为卡片设置长按事件以启动特定卡片的操作表。帮我把这个长按事件绑定到 ionic

标签: ionic-framework

解决方案


Ionic 4 手势:安装 HammerJs。

npm install hammerjs

里面: src/main.ts

/**
 * Hammerjs must be imported for gestures
 */
import 'hammerjs';

您可以执行以下操作:

<ion-card (press)="tapEvent($event)">
  <ion-item>
    Tapped: {{tap}} times
  </ion-item>
</ion-card>

在 .ts

tapEvent(e){
    console.log(e);
    this.tap++;
}

推荐阅读