TypeError: p.easing [ this. easing ]不是一个函数

当试图用 jQuery 显示一个 div 元素时,我得到了这个错误:

[23:50:35.971] TypeError: p.easing[this.easing] is not a function @ file:///D:/html5%20puzzle/jquery.js:2

相关的功能是:

function showWithAnimation(){
console.log('animation called');
$('#popup').show();
$("#popup").css({"top": "30%", "left": "30%"})
.animate({top:(($(window).height()/2)-($('#popup')
.outerHeight()/2))-70}, 1000, 'easeOutBounce')
.show();
}

该函数负责用弹跳动画显示 div,然而,div 被显示但没有弹跳效果。

编辑:

我从一个 CDN 中包含了 jQuery 和 jQueryUI 库,如下所示(按顺序) :

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js'>
</script>
209918 次浏览

You need to include jQueryUI for the extended easing options.

I think there may be an option to only include the easing in the download, or at least just the base library plus easing.

Jquery easing plugin renamed their effect function names from version 1.2 on. If you have some javascript depending on easing and it is not calling the right effect name it will throw this error.

For those who have a custom jQuery UI build (bower for ex.), add the effects core located in ..\jquery-ui\ui\effect.js.

I got this error today whilst trying to initiate a slide effect on a div. Thanks to the answer from 'I Hate Lazy' above (which I've upvoted), I went looking for a custom jQuery UI script, and you can in fact build your own file directly on the jQuery ui website http://jqueryui.com/download/. All you have to do is mark the effect(s) that you're looking for and then download.

I was looking for the slide effect. So I first unchecked all the checkboxes, then clicked on the 'slide effect' checkbox and the page automatically then checks those other components necessary to make the slide effect work. Very simple.

easeOutBounce is an easing effect, for which you'll need to check the 'Effects Core' checkbox.

If you're using Bootstrap it's also possible that Bootstrap's jQuery, if included below your jQuery script tag, is overwriting your jQuery script tag with another version. Including jQuery's own CDN and deleting the jQuery script tag that Bootstrap provides was the only thing that worked for me.

Including this worked for me.

Please include the line mentioned below in the section.

<script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js'>

I have found the problem: Don't use CDN (this is causing the problem!), instead save the jquery file locally on your server and then the problem is away.

For anyone going through this error and you've tried updating versions and making sure effects core is present etc and still scratching your head. Check the documentation for animate() and other syntax.

All I did was write "Linear" instead of "linear" and got the [this.easing] is not a function

$("#main").animate({ scrollLeft: '187px'}, 'slow', 'Linear'); //bad

$("#main").animate({ scrollLeft: '187px'}, 'slow', 'linear'); //good

Importing jquery.easing cdn worked for me.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js"></script>

You can add this bottom of the webpage.

use the latest one for bootstrap 4 and above, this won't affect your UI

I discovered a very strange thing, but important to know: When you installed jQuery ui (1.12.1) a lot of easings work, e.g.:

jQuery('#my-elm').animate({marginLeft:500},1000,'linear');
jQuery('#my-elm').animate({marginLeft:500},1000,'easeOutBounce');

works, but the default:

jQuery('#my-elm').animate({marginLeft:500},1000,'swipe');

generates very many errors

In my case it was an error in the js code. Once i fixed it the error went away. The error was something like this.

$("#id").removeClass("class-1","class-2","class-3");

Apparently this isn't how to remove multiple classes at a time.