Home >Web Front-end >JS Tutorial >How to solve the problem when seajs loads jquery and prompts $ is not a function_jquery
Jquery 1.7 and above all support modular loading, but jquery supports amd by default and does not support cmd. So when we want to use seajs to load jquery, we need to make slight changes. We need to modify the following content. The specific modification methods are as follows:
Put it
if (typeof define === "function" && (define.amd)) { define( "jquery", [], function() { return jQuery; }); }
changed to
if (typeof define === "function" && (define.amd || define.cmd)) { define( "jquery", [], function() { return jQuery; }); }
or
if (typeof define === "function") { define( "jquery", [], function() { return jQuery; }); }
By modifying the above code, you can successfully solve the problem of $ is not a function when seajs loads jquery. I hope it will be helpful to everyone.