我正在使用循环滑块,使用 jquery 4.0 时会出现以下错误。data.hasOwnProperty 不是此代码段上的函数。您能否建议如何修复此问题?谢谢
return this.each(function() {
var data, opts, shortName, val;
var container = $(this);
var log = $.fn.cycle2.log;
if ( container.data('cycle2.opts') )
return; // already initialized
if ( container.data('cycle2-log') === false ||
( options && options.log === false ) ||
( opts && opts.log === false) ) {
log = $.noop;
}
log('--c2 init--');
data = container.data();
for (var p in data) {
// allow props to be accessed sans 'cycle2' prefix and log the overrides
if (data.hasOwnProperty(p) && /^cycle2[A-Z]+/.test(p) ) {
val = data[p];
shortName = p.match(/^cycle2(.*)/)[1].replace(/^[A-Z]/, lowerCase);
log(shortName+':', val, '('+typeof val +')');
data[shortName] = val;
}
}
opts = $.extend( {}, $.fn.cycle2.defaults, data, options || {});