typescript - ionic 滑动手势不适用于手机

标签 typescript ionic-framework ionic2 gesture ionic3

我尝试做一个滑动手势来在选项卡之间切换。我希望该手势适用于整个屏幕。我捕获了滑动 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/

相关文章:

javascript - 一个函数中的 Angular 组件类变量集在另一个函数中未定义

reactjs - 类型 'name' 上不存在属性 'EventTarget' - React + TypeScript

javascript - 在 Controller 中访问 $ionicConfigProvider

Angular 2 - 如何访问指令并在其中调用成员函数

javascript - Ionic 2 的 $on ("$ionicView.beforeEnter") 是什么?

angular - 如何从 Angular 6 中的父组件调用子组件的方法

javascript - Tween.js 不调用 onUpdate 函数

javascript - 谷歌地图信息窗口按钮( ionic )问题

html - 我们如何将所需的 CSS 应用于完整的 ionic 应用程序框架

ionic2 - Ionic 2 - 如何存储全局变量?