我尝试做一个滑动手势来在选项卡之间切换。我希望该手势适用于整个屏幕。我捕获了滑动 Action
<ion-content (swipe)="swipeEvent($event)">
swipeEvent 函数是
swipeEvent(e) {
if(e.direction == '2'){
this.navCtrl.parent.select(2);
}
else if(e.direction == '4'){
this.navCtrl.parent.select(0);
}
}
它在浏览器中运行良好。但是当我在手机中构建它时,手势没有任何效果。 有没有其他解决方案?
最佳答案
这是 Ionic 团队成员的解决方案:See this too .
It's not really recommended to use swipe gestures on the main content. Since ion-content is a input for gestures anyways (scrolling and such) it having swipe on it can just cause confusion. Instead, putting the event handler on a child element works fine.
<ion-content padding>
<ion-card (swipe)="swipeEvent($event)">
<ion-item>
</ion-item>
</ion-card>
</ion-content>
关于typescript - ionic 滑动手势不适用于手机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45574491/