jQuery 1.9.1 中的“TypeError: jQuery.easing[this.easing] 不是函数”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15719456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 15:39:41  来源:igfitidea点击:

"TypeError: jQuery.easing[this.easing] is not a function" in jQuery 1.9.1

jqueryjquery-uijquery-plugins

提问by OsakaWebbie

For the first time in too many months (blush), I upgraded my jQuery stuff. I'm now on:

几个月来第一次(脸红),我升级了我的 jQuery 东西。我现在在:

  • jquery-1.9.1.js
  • jquery-ui-1.10.2.custom.js (used ThemeRoller, and included all components, including the Effects Core, which mentions easing in its description)
  • jquery-1.9.1.js
  • jquery-ui-1.10.2.custom.js(使用 ThemeRoller,包括所有组件,包括 Effects Core,它在描述中提到了缓动)

I also upgraded to the most recent versions of jquery.multiselect and jquery.multiselect.filter plugins. When I try to close one of the multiselect menus, I get this error:

我还升级到最新版本的 jquery.multiselect 和 jquery.multiselect.filter 插件。当我尝试关闭多选菜单之一时,出现此错误:

TypeError: jQuery.easing[this.easing] is not a function
jquery-1.9.1.js (line 9033)

Note that although I'm using the multiselect plugin when the error occurs, the actual error is in the main jQuery file. The code is:

请注意,虽然我在发生错误时使用了多选插件,但实际错误在主 jQuery 文件中。代码是:

/*9031*/ if ( this.options.duration ) {
/*9032*/   this.pos = eased = jQuery.easing[ this.easing ](
/*9033*/     percent, this.options.duration * percent, 0, 1, this.options.duration
/*9034*/   );
/*9035*/ }

Did I forget to update some file? Googling about it, others with the same complaint seem to all be trying to use some sort of additional easing plugin, but I'm not.

我忘记更新一些文件了吗?谷歌搜索,其他有同样抱怨的人似乎都在尝试使用某种额外的缓动插件,但我不是。

回答by Martin Sansone - MiOEE

This error could happen in various animations throughout your site when first upgrading to jQuery 1.9.+ because the easing effect names have changed !!!

首次升级到 jQuery 1.9.+ 时,整个站点的各种动画中可能会发生此错误,因为缓动效果名称已更改!!!

See http://api.jqueryui.com/easings/What doesn't help is that the old examples in the jQueryUI.com site havent been updated, leading folks to think that the old animate example names are correct.

请参阅http://api.jqueryui.com/easings/没有帮助的是 jQueryUI.com 站点中的旧示例尚未更新,导致人们认为旧的动画示例名称是正确的。

Example:accordion panels "bounceslide" animation is now a close version of something called 'easeOutBounce'. The string "bounceslide" is still in the sites' example as of this writing: http://api.jqueryui.com/accordion/#option-animate.

示例:手风琴面板“bounceslide”动画现在是名为“ easeOutBounce”的接近版本。在撰写本文时,字符串“bounceslide”仍在网站的示例中:http://api.jqueryui.com/accordion/#option-animate 。

I only realised the animation names had changed after following the hyperlink mentioned in the animate types and trying the new names out within my code.

在遵循动画类型中提到的超链接并在我的代码中尝试新名称后,我才意识到动画名称已更改。

回答by Nalan Madheswaran

Include:

包括:

<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>    

Note: update the jquery UI version if needed.

注意:如果需要,更新 jquery UI 版本。

回答by dewd

Invalid 2nd Argument Issue

无效的第二个参数问题

In case this helps someone stumbling upon this question like I did when I got this error, I'll add another possible solution. My error was due to the fact that my 2nd argument to the fadeInfunction was not a "callback" function to be executed on completion of the animation. If the 2nd argument is not a function, jQuery expects it to be a type of easing to use. My 2nd argument was mistakenly an object - I thought it was a function.

如果这有助于像我遇到此错误时那样绊倒这个问题的人,我将添加另一个可能的解决方案。我的错误是由于我对该fadeIn函数的第二个参数不是要在动画完成时执行的“回调”函数。如果第二个参数不是函数,jQuery 期望它是一种易于使用的类型。我的第二个参数错误地是一个对象——我认为它是一个函数

So, for me,

所以,对我来说,

return {
  enter: function(element,classes,done){ //classes variable incorrectly added, making done an object
    element.fadeIn(1000,done);
  }
};

became:

变成了:

return {
  enter: function(element,done){ //remove classes variable as wasn't right for this situation - done is now a function
    element.fadeIn(1000,done);
  }
};

Note, the change in arguments passed into my anonymous enterfunction. Importantly in my case, these variables were AngularJS injections, so the order they were in was important, not so much their name.

请注意,传入我的匿名enter函数的参数更改。重要的是,在我的例子中,这些变量是 AngularJS 注入,所以它们的顺序很重要,而不是它们的名字。

回答by Fabian Horlacher

The error can be provoked by argument inversionwhen using an effect method wrongly like .show(duration, easing)as it leads to a call of an invalid easing.

当错误地使用效果方法时,参数反转可能会引发该错误,例如.show(duration, easing)它会导致调用无效的缓动。

The correct notation is .show(easing, duration)https://api.jquery.com/show/

正确的符号是.show(easing, duration)https://api.jquery.com/show/

var duration = 'slow', easing = 'linear';
$("#correct").click(function() {
  $("p").show(duration, easing);
});
$("#error").click(function() {
  $("p").show(easing, duration); // fails -> see error in console
});
p { background: yellow; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
$("p").show(
<button id="correct">duration, easing</button>
<button id="error">easing, duration -> ERROR</button>
)
<p style="display: none">Hello</p>

回答by AamirR

Thanks to @Legionar's comment, upgrade to his suggested version 1.13worked for me:

感谢@Legionar 的评论,升级到他建议的版本1.13对我有用:

https://github.com/ehynds/jquery-ui-multiselect-widget/archive/1.13.zip

UPDATEin this version the usage of outerHeight()function causes the widget to position wrong because it misses css position top, changing line#573 to following will get the issue fixed:

在此版本中更新outerHeight()函数的使用导致小部件定位错误,因为它缺少 css position top,将 line#573 更改为以下将解决问题:

top: pos.top + button.outerHeight(false),

回答by Adjaro Lord Ogaga

This has absolutely nothing to do with versions.

这与版本完全无关。

I had this code and got the same error:

我有这个代码并得到同样的错误:

$("#consoleBtn").click(function(){
    $("#consolePanel").toggle("display", {  from : { display: "block" }, to : { display: "none" } });
});

The problem was the arguments I passed to the toggle function. So I changed to:

问题是我传递给切换函数的参数。所以我改为:

$("#consoleBtn").click(function(){
    $("#consolePanel").toggle();
});

So be mindful of the arguments passed to your function when calling jQuery-api. Hope this helps.

所以在调用 jQuery-api 时要注意传递给你的函数的参数。希望这可以帮助。