如何在ionic 4 angular项目中全局禁用向后滑动手势

Mar*_*sel 4 gesture ios ionic-framework angular ionic4

已经尝试通过以下方法实现此目的:

<ion-router-outlet swipeGesture="false" animated="false"></ion-router-outlet>
Run Code Online (Sandbox Code Playgroud)

并在app.module中:

IonicModule.forRoot({
    swipeBackEnabled: false
}),
Run Code Online (Sandbox Code Playgroud)

config.xml:

<preference name="AllowBackForwardNavigationGestures" value="false" />
Run Code Online (Sandbox Code Playgroud)

..但水平滑动手势仍会触发导航到其他页面:-(

我可以想到并部分但未成功尝试的可能方式是:

  1. 使用弃用的离子navController以某种方式?
  2. 使用hammerJS?
  3. 使用未记录的GestureController(https://github.com/ionic-team/ionic/tree/a77ee2a6f88e8defb1763b71e77410264fafac70/core/src/utils/gesture

如果有人可以指出正确的方向或提供一个示例(主要针对iOS)如何禁止滑动,我将非常高兴,非常感谢

And*_*ann 13

我通过添加[swipeGesture]="false"ion-router-outlet此处所述解决了它:https : //github.com/ionic-team/ionic/issues/16441

一开始,我犯了将其添加到文件中所有ion-router-outlets 的错误tabs.html。那没用。相反,你只需将它添加到ion-router-outlet了在app.component.html文件中。那对我有用。

app.component.html

<ion-app>
  <ion-router-outlet [swipeGesture]="false"></ion-router-outlet>
</ion-app>
Run Code Online (Sandbox Code Playgroud)

我正在使用离子版本4.0.0-beta.17

  • 这不适用于具有后退按钮的子页面。 (3认同)