问题描述
我正在使用 jquery.event.move 在触摸设备上创建移动事件.该脚本在第580行上引发了错误.
I'm using jquery.event.move to create move events on touch devices.The script is throwing an error on line 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中不应该存在此数组吗?我已经将jquery作为宝石安装"在我的rails应用程序中(jquery-rails 4.1.1)知道我能做什么吗?
When it gets to line 580 it throws Uncaught TypeError: Cannot read property 'indexOf' of undefined
The way I understand it is that jQuery.event.props is undefined? Shouldn't this array be present by default in jquery?I've "installed" jQuery in my rails app as a gem (jquery-rails 4.1.1)Any idea what I could do?
推荐答案
jquery版本3或更高版本存在问题,如 jquery.event.move
github issue 页面:
There is an issue with jquery version 3 or above as mentioned in the jquery.event.move
github issue page:
jQuery 3.0.0中断了jQuery.event.props
的使用
这是因为在jQuery 3.0.0升级中删除了jQuery.event.props
和jQuery.event.fixHooks
.这里有更多详细信息:
This happened since in jQuery 3.0.0 upgrade jQuery.event.props
and jQuery.event.fixHooks
are removed. More details here:
重大更改:已删除jQuery.event.props
和jQuery.event.fixHooks
github问题仍未解决,截至2016年1月8日尚未提供解决方案.作为替代解决方案,您可以:-
The github issue is still open and no solution has been provided yet as of 08.01.2016. As an alternative fix you can either:-
- 使用jQuery Migrate插件,该插件为这些插件提供支持特性.
- 或者,使用3.0.0以下的任何jQuery版本
- Use the jQuery Migrate plugin, which provides support for theseproperties.
- Or, use any jQuery version below 3.0.0
这篇关于jQuery.event.props未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!