jQuery-UI – “无法读取未定义的属性’步骤’

我们最近将jQuery从2.2.4升级到3.1.1,现在看到一些有趣的错误。 我安装了jquery-migrate插件,它帮助我解决了一些错误,但并非全部。 以下是我在Chrome浏览器控制台中看到的错误,我似乎无法确定发生此错误的位置。

 jquery-ui-1.12.1.js:1951 Uncaught TypeError: Cannot read property 'step' of undefined at String. (jquery-ui-1.12.1.js:1951) at each (jquery-3.1.1.slim.js:368) at Function.color.hook (jquery-ui-1.12.1.js:1913) at jquery-ui-1.12.1.js:1963 at jquery-ui-1.12.1.js:2005 at jquery-ui-1.12.1.js:14 at jquery-ui-1.12.1.js:16 

我在Chrome中进行了调试,它打破了一个名为jQuery.fx.step[ hook ]的函数。 当我将鼠标hover在jQuery.fx ,它显示为未定义。 见下文

 jQuery.fx.step[ hook ] = function( fx ) { if ( !fx.colorInit ) { fx.start = color( fx.elem, hook ); fx.end = color( fx.end ); fx.colorInit = true; } 

我已经卸载了jquery-ui ,但所有这些都是打破Angular。 如果有人能够对此事有所了解,那会很高兴。

packages.config =

                      

基于错误消息,它看起来像你正在使用jQuery Slim(来自at each (jquery-3.1.1.slim.js:368) )。 Slim显然删除了jQuery UI中所需的一些function。 要解决此问题,请使用完整版的jQu​​ery。

这是一个复制您的问题的演示:

 $( function() { // run the currently selected effect function runEffect() { // get effect type from var selectedEffect = $( "#effectTypes" ).val(); // Most effect types need no options passed by default var options = {}; // some effects have required parameters if ( selectedEffect === "scale" ) { options = { percent: 50 }; } else if ( selectedEffect === "transfer" ) { options = { to: "#button", className: "ui-effects-transfer" }; } else if ( selectedEffect === "size" ) { options = { to: { width: 200, height: 60 } }; } // Run the effect $( "#effect" ).effect( selectedEffect, options, 500, callback ); }; // Callback function to bring a hidden box back function callback() { setTimeout(function() { $( "#effect" ).removeAttr( "style" ).hide().fadeIn(); }, 1000 ); }; // Set effect from select menu value $( "#button" ).on( "click", function() { runEffect(); return false; }); } ); 
 .toggler { width: 500px; height: 200px; position: relative; } #button { padding: .5em 1em; text-decoration: none; } #effect { width: 240px; height: 170px; padding: 0.4em; position: relative; } #effect h3 { margin: 0; padding: 0.4em; text-align: center; } .ui-effects-transfer { border: 2px dotted gray; } 
    

Effect

Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede. Nulla lorem metus, adipiscing ut, luctus sed, hendrerit vitae, mi.

只是使用不同的cdn我从bootstrap网站使用cdn它不工作jquery cdn

这可能是由于jquery slim版本