问题
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] is not a function" (firefox)
"Uncaught TypeError: Property 'undefined' of object # is not a function" (chrome)
I include my JS like this:
<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>
My main JS page looks like this: http://thebeer.co/js/built/mesh-built.js
require(["globals","functionBank"],function(gb,r){
//myapp code
});
globals looks like this:
http://thebeer.co/js/globals.js
and functionbank looks like this:
http://thebeer.co/js/functionBank.js
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: This problem is only evident once the scripts have been optimised by requireJS...
回答1:
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.
来源:https://stackoverflow.com/questions/5171378/requirejs-problem-including-jquery-easing-pack-after-optimization