Javascript 类型错误:p.easing[this.easing] 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12592279/
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
TypeError: p.easing[this.easing] is not a function
提问by Malloc
When trying to show a div element with jQuery, i got this error:
尝试使用 jQuery 显示 div 元素时,出现此错误:
[23:50:35.971] TypeError: p.easing[this.easing] is not a function @ file:///D:/html5%20puzzle/jquery.js:2
The relevant function is this:
相关功能是这样的:
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();
}
The function is responsible of showing the div with a bounce animation, however, the div is shown but without bounce effect.
该函数负责显示带有反弹动画的 div,但是,显示 div 但没有反弹效果。
EDIT:
编辑:
I am including jQuery and jQueryUI libraries from a CDN like this (In order):
我从这样的 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>
回答by I Hate Lazy
You need to include jQueryUI for the extended easing options.
您需要为扩展缓动选项包含 jQueryUI。
I think there may be an option to only include the easing in the download, or at least just the base library plus easing.
我认为可能有一个选项,只在下载中包含缓动,或者至少只包含基础库和缓动。
回答by Tim Vermaelen
For those who have a custom jQuery UI build (bower for ex.), add the effects core located in ..\jquery-ui\ui\effect.js
.
对于那些拥有自定义 jQuery UI 构建(例如 bower)的人,添加位于..\jquery-ui\ui\effect.js
.
回答by Manju
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'>
回答by ericopter
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.
从 1.2 版开始,Jquery 缓动插件重命名了它们的效果函数名称。如果您有一些依赖于缓动的 javascript 并且它没有调用正确的效果名称,它将抛出此错误。
回答by luke_mclachlan
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.
我今天在尝试在 div 上启动幻灯片效果时遇到了这个错误。感谢上面“我讨厌懒惰”的回答(我已经投票赞成),我开始寻找自定义 jQuery UI 脚本,实际上您可以直接在 jQuery ui 网站http://jqueryui上构建自己的文件。 com/下载/。您所要做的就是标记您正在寻找的效果,然后下载。
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.
easeOutBounce 是一种缓动效果,您需要选中“Effects Core”复选框。
回答by Matthew Hinea
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.
如果您正在使用 Bootstrap,则 Bootstrap 的 jQuery(如果包含在您的 jQuery 脚本标签下方)也可能会用另一个版本覆盖您的 jQuery 脚本标签。包括 jQuery 自己的 CDN 并删除 Bootstrap 提供的 jQuery 脚本标记是唯一对我有用的方法。
回答by Pasodoble
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.
我发现了问题:不要使用 CDN(这是导致问题的原因!),而是将 jquery 文件保存在您的服务器本地,然后问题就消失了。
回答by tree
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.
对于任何遇到此错误并且您已经尝试更新版本并确保存在效果核心等但仍然摸不着头脑的人。检查 animate() 和其他语法的文档。
All I did was write "Linear" instead of "linear" and got the [this.easing] is not a function
我所做的只是写了“线性”而不是“线性”并且得到了 [this.easing] 不是一个函数
$("#main").animate({ scrollLeft: '187px'}, 'slow', 'Linear'); //bad
$("#main").animate({ scrollLeft: '187px'}, 'slow', 'Linear'); //坏的
$("#main").animate({ scrollLeft: '187px'}, 'slow', 'linear'); //good
$("#main").animate({ scrollLeft: '187px'}, 'slow', 'linear'); //好的
回答by FaridLU
Importing jquery.easing
cdn worked for me.
导入jquery.easing
cdn 对我有用。
<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.
您可以在网页底部添加此内容。