在ionic3中手势事件是不需要引入其它模块的,但是ionic4中需要引入插件,直接使用是没有反应的,而且在ionic4的官网中也没有提供手势事件的相关知识。那么手势事件中都有哪些呢?
tap 点击事件
press 长按事件
pan 滑动的时候触发的事件,滑动触发多次
swipe 滑动事件 滑动触发一次
rotate 旋转事件
pinch 捏合(pinch)手势
1. 首先需要安装hammer.js
nmp install hammerjs --save
2. 在项目的src/main.ts中引入hammer.js
import 'hammerjs';
3. 安装并引入hammerjs 后就可以在ionic4模板中使用手势事件
<ion-card (press)="presentActionSheet()" style="margin-top:4%;margin-bottom: 1%" *ngFor="let tasks of tasks" [ngStyle]="{'background-color': '#339efc'}">
<ion-card-content class="taskName" >
{{tasks.tomatoName}}
</ion-card-content>
<ion-card-content class="start" >
<p>开始</p>
</ion-card-content>
</ion-card>```