[英]velocity.js file is there but function not working
I am new to this and I am trying to make velocity.js work on a site I'm building. 我对此并不陌生,我正在尝试使Velocity.js在我正在构建的网站上工作。 I included velocity.js on my index.php page and I also included velocity.ui.js after I included velocity.js
我在index.php页面上包含了Velocity.js,在包含了Velocity.js之后也包含了Velocity.ui.js。
I then replace all instances of animate() with velocity() like the instructions said. 然后,按照上述说明,将所有animate()实例替换为velocity()。 None of the animations work and I get an error velocity is not a function.
没有动画起作用,并且我得到错误速度不是函数。 So I am trying to learn this and so I looked at the two files I included and I cannot find velocity as a function, so how is this supposed to work then?
因此,我试图学习这一点,所以我查看了包含的两个文件,但找不到速度作为函数,那么这应该如何工作?
This is what the instructions say: 指令说明如下:
"Download Velocity, include it on your page, and replace all instances of jQuery's $.animate() with $.velocity(). You will immediately see a performance boost across all browsers and devices — especially on mobile."
“下载Velocity,将其包含在页面中,并用$ .velocity()替换jQuery的$ .animate()的所有实例。您将立即看到所有浏览器和设备(尤其是在移动设备上)的性能提升。”
What am I doing wrong please? 请问我做错了什么?
So is this the right way or not? 那么这是正确的方法吗?
$('#elements1, #elements2').velocity({opacity: 1}, 900);
$('#elements1,#elements2')。velocity({opacity:1},900);
I used the CDN and I still get a velocity is not a function error. 我使用了CDN,但仍然得到速度不是函数错误。
put velocity.js and index.php in same folder or specify the correct path of velocity.js in index.php . 将Velocity.js和index.php放在同一文件夹中,或在index.php中指定Velocity.js的正确路径 。 I hope this might help you.
希望对您有所帮助。
Make sure you load jQuery before VelocityJS - if it's done in the wrong order then Velocity won't know jQuery exists and will bind as window.Velocity()
instead - which needs calling in a slightly different way. 确保在 VelocityJS 之前加载
window.Velocity()
如果执行顺序错误,则Velocity将不知道jQuery的存在,而是将其绑定为window.Velocity()
-需要以略有不同的方式进行调用。
edit: For future reference, the jQuery and VelocityJS order was right, but the user functions were being loaded between the two and not waiting for document.ready
- hence confusing debugging. 编辑:为了将来参考,jQuery和VelocityJS的顺序是正确的,但是用户函数正在两者之间加载,而没有等待
document.ready
从而使调试混乱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.