我正在使用Framework7 sortable list它工作得很好,只是当列表更改时它不会触发事件。
所以我正在尝试一些内置事件:
$('.sortable-handler').on('touchstart', function (e) {
e.preventDefault();
alert('touchstart');
});
$('.sortable-handler').on('touchmove', function (e) {
e.preventDefault();
console.log('touchmove');
});
$('.sortable-handler').on('touchcancel', function (e) {
e.preventDefault();
console.log('touchcancel');
});
$('.sortable-handler').mouseleave(function (e) {
e.preventDefault();
console.log('mouseleave');
});
..但我得到的是:
Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080
我应该寻找哪个事件来获取每种类别的更新列表?
最佳答案
查看此blog post 。如果您在每个 touchstart
上调用 preventDefault
,那么您还应该有一个 CSS 规则来禁用触摸滚动,例如
.sortable-handler {
touch-action: none;
}
关于javascript - 无法阻止被动事件监听器内的默认行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52150876/