我以前用Ionic Angular为整个应用程序做过这样的事情:
IonicModule.forRoot({ swipeBackEnabled: false })
或者通过注入IonRouterOutlet来获取单个页面:
this.routerOutlet.swipeGesture = true;
但是,我如何在Ionic Vue应用程序上执行此操作?
我使用以下命令禁用全局滑动:
app.use(IonicVue, {swipeBackEnabled: false})
但是如果我在页面上导入IonRouterOutlet,它就没有swipeGesture属性,并且我不知道如何在单个页面上禁用该选项。
发布于 2021-04-09 10:40:54
您可以在应用程序中全局禁用swipeGesture,方法是将[swipeGesture]="false"
添加到src
根目录下的App.vue
文件中的ion-router-outlet
中:
<template>
<ion-app>
<Header />
<ion-router-outlet [swipeGesture]="false" />
</ion-app>
</template>
发布于 2021-05-28 14:57:58
仅限iOS :我发现了一种有效但并不美观的方法。
首先,从@ createGesture /vue导入离子函数。
import { createGesture } from '@ionic/vue';
然后,必须在ionViewWillEnter中覆盖标准的向后滑动手势。
const gesture = createGesture({
el: document.getElementById('test'),
threshold: 0,
gestureName: 'goback-swipe',
gesturePriority: 40.5, // priority of swipe to go back is 40
onMove: ev => console.log(ev)
});
gesture.enable(true);
然后给ion-page对象一个ID,并对其应用手势。
<ion-page id="test">
发布于 2021-09-19 17:17:06
Phil0xFF感谢您的解决方案。
我根据您的决定创建了v-disable-swipe-back
指令
享受您的使用)
npm i v-disable-swipe-back
<ion-page v-disable-swipe-back>
https://stackoverflow.com/questions/66567255
复制相似问题