gpt4 book ai didi

jQuery.event.props 未定义

转载 作者:行者123 更新时间:2023-12-03 22:31:24 28 4
gpt4 key购买 nike

我正在使用jquery.event.move在触摸设备上创建移动事件。该脚本在第 580 行抛出错误。

570 // Make jQuery copy touch event properties over to the jQuery event
571 // object, if they are not already listed. But only do the ones we
572 // really need. IE7/8 do not have Array#indexOf(), but nor do they
573 // have touch events, so let's assume we can ignore them.
574 if (typeof Array.prototype.indexOf === 'function') {
575 (function(jQuery, undefined){
576 var props = ["changedTouches", "targetTouches"],
577 l = props.length;
578
579 while (l--) {
580 if (jQuery.event.props.indexOf(props[l]) === -1) {
581 jQuery.event.props.push(props[l]);
582 }
583 }
584 })(jQuery);
585 };

当到达第 580 行时,它会抛出Uncaught TypeError: Cannot read property 'indexOf' of undefined我的理解是 jQuery.event.props 未定义?这个数组不应该默认存在于 jquery 中吗?我已经在我的 Rails 应用程序中“安装”了 jQuery 作为 gem (jquery-rails 4.1.1)知道我能做什么吗?

最佳答案

jquery 版本 3 或更高版本存在问题,如 jquery.event.move 中所述。 github issue页面:

jQuery 3.0.0 breaks jQuery.event.props usage

发生这种情况是因为在 jQuery 3.0.0 升级中,jQuery.event.propsjQuery.event.fixHooks 被删除。更多详细信息请参见:

Breaking change: jQuery.event.props and jQuery.event.fixHooks removed

jQuery's event handling performance increased thanks to a reorganization of event property management. The main improvement is that jQuery now only calculates or copies a property on the first access, rather than calculating and copying them up front. This is a really big win with properties that may force layout that the event handler may not even need. The most common use we know of was to add properties for pointer events, which is no longer necessary because those events are supported already in jQuery 3.0. The jQuery Migrate plugin provides support for these properties if you still need them. The related but undocumented mouseHooks and keyHooks lists were removed as well. The team is interested in understanding other use cases before defining new APIs, so feel free to open a ticket.

截至 2016 年 1 月 8 日,github 问题仍然悬而未决,尚未提供解决方案。作为替代修复,您可以:-

  • 使用 jQuery Migrate 插件,它为这些提供支持特性。
  • 或者,使用 3.0.0 以下的任何 jQuery 版本

关于jQuery.event.props 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38682004/

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