首页 > Web开发 > 详细

PJax在jQuery 3.0无法运行问题修复

时间:2016-12-02 18:47:07      阅读:1080      评论:0      收藏:0      [点我收藏+]

PJax在jQuery 3.0无法运行

【现象】

页面报错:Uncaught TypeError: Cannot read property ‘push‘ of undefined

【原因】

jQuery3.0开始去除了$.event.props

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.

 【修改】

方法一:用addProp代替 props.push。

if ( $.event.props && $.inArray(‘state‘, $.event.props) < 0 ) {
  $.event.props.push(‘state‘);
} else if ( ! (‘state‘ in $.Event.prototype) ) {
  $.event.addProp(‘state‘);
}

方法二:使用jQuery 3.0 的migrate版本

 

参见GitHub,PJax官网 issue 634.

 

PJax在jQuery 3.0无法运行问题修复

原文:http://www.cnblogs.com/dcchan/p/6126548.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!