RequireJS:优化后包括jquery缓动包的问题 [英] RequireJS : Problem including jquery easing pack after optimization

查看:98
本文介绍了RequireJS:优化后包括jquery缓动包的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将jquery缓动包包含到我的应用程序中。在requireJS文件被优化之前,它可以正常工作。现在我使用优化版本,当我调用使用缓动的动画时我得到了这个错误:

I want to include the jquery easing pack into my application. Before requireJS files have been 'optimized' it works fine. Now I am using the optimized version when ever I call an animation that uses easing I get this error:

jQuery.easing [jQuery.easing.def]不是function(firefox)

"jQuery.easing[jQuery.easing.def] is not a function" (firefox)

未捕获TypeError:对象#的属性'未定义'不是函数(chrome)

"Uncaught TypeError: Property 'undefined' of object # is not a function" (chrome)

我这样包含我的JS:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
<script src="http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js"></script>
<script data-main="/js/mesh-built.js" src="/js/libs/require.js"></script>






我的主JS页面看起来像这样:
http://thebeer.co/js/built/ mesh-built.js

require(["globals","functionBank"],function(gb,r){

//myapp code

});






全局变量如下:

http://thebeer.co/ js / globals.js

,函数库看起来像这样:

http://thebeer.co/js/functionBank。 js

我唯一想到的是因为jquery被声明为全局变量和函数中的依赖关系在没有附加缓和包的情况下被传递?我应该在主要的requireJS文件中附加缓动插件吗?

My only thought is that becuase jquery is stated as a dependency within globals and functions it is somehow being passed in without the easing pack attached? Should I attach the easing plugin from within the main requireJS file instead?

FORGOT TO MENTION:
这个问题只有在脚本出现后才会出现由requireJS优化...

FORGOT TO MENTION: This problem is only evident once the scripts have been optimised by requireJS...

推荐答案

mesh-built.js文件似乎包含require.js内容。最好不要包含require.js(确保在构建配置文件中指定includeRequire:true 。我首先想到的是这个重复的需要导致问题,它可能没有正确引用jQuery,它被用来处理built.js文件。

The mesh-built.js file seems to include require.js contents. It is best if it does not include require.js (make sure that includeRequire: true is not specified in the build profile. My first thought is this duplicate require is causing the problem, it may not have the correct reference to jQuery and it is being used to handle the built.js file.

这篇关于RequireJS:优化后包括jquery缓动包的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆