javascript - Chrome - 由于目标被视为被动,无法在被动事件侦听器中阻止默认值
问题描述
我在下面使用 chrome 时遇到错误
错误:
[干预] 由于目标被视为被动,无法阻止被动事件侦听器内部的默认值。看
url
代码:
$('body').on("wheel", "form input[type=number]", function (e) {
e.preventDefault();
});
如果用户在数字输入字段内使用鼠标滚轮,上面的代码用于防止对数字字段进行更改。
我最近收到此错误,前几天没有此类错误!
*更新:
我试过添加
{
passive: true
}
像这样:
$('body').on("wheel", "form input[type=number]", function (e) {
e.preventDefault();
}, {passive: true});
另一个错误显示:
jquery.min.js:3 Uncaught TypeError: ((r.event.special[g.origType] || {}).handle || g.handler).apply is not a function at HTMLBodyElement.dispatch (jquery.min.js:3) at HTMLBodyElement.q.handle (jquery.min.js:3)
如何修复错误并防止数字字段内的鼠标滚轮?
铬版: Chrome 78 on Windows 10
解决方案
推荐阅读
- r - 根据文件在 R 中的名称将文件组合到数据帧中
- python - 根据列表内容验证用户输入的最佳方法是什么?
- firebase - Firebase Web / 将文件上传到 Firebase 存储不起作用
- sql - 带有来自表的列和排序信息的动态排序依据子句?
- delphi - 如何在 Delphi 中读取 MP3 文件进行音频处理?
- objective-c - 将两位十六进制数转换为整数的最佳方法
- java - 使用 Junit 对边缘案例进行单元测试
- javascript - Fullcalendar TypeError:无法读取 null 的属性“顶部”
- mysql - Mysql:尽管文件内容包含数据,但最终字段中的空字段
- amazon-web-services - MongoDB BSON 文档在 Flask 应用程序上出现太大错误,但在独立执行时运行良好