gpt4 book ai didi

javascript - ionic 手势在移动设备中不起作用

转载 作者:行者123 更新时间:2023-12-04 02:10:51 24 4
gpt4 key购买 nike

我正在尝试使用 ionic 框架在我的应用程序中使用滑动手势。该代码在我的浏览器中运行良好,但当我在移动设备中安装/运行它时,没有手势工作。

这是我的代码

app.directive('detectGestures', function ($ionicGesture) {
return {
restrict: 'A',

link: function (scope, elem, attrs) {
var gestureType = attrs.gestureType;
$ionicGesture.on('swipeup', scope.reportEvent, elem);
$ionicGesture.on('swipedown', scope.reportEvent, elem);
$ionicGesture.on('swiperight', scope.reportEvent, elem);
$ionicGesture.on('swipeleft', scope.reportEvent, elem);
}
};
});

Controller.js

$scope.reportEvent = function (event) {
alert("1");
console.log('Reporting : ' + event.type);
event.preventDefault();

login();
};

最佳答案

我在我的 ion-content 中执行滑动事件:

<ion-content on-swipe-left="swipe();">

在 Controller 中:

$scope.swipe = function () {
$state.go("main.agenda.allEvents");
}

成功了。

关于javascript - ionic 手势在移动设备中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30587741/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com