Home >Web Front-end >JS Tutorial >How to solve the problem when seajs loads jquery and prompts $ is not a function_jquery

How to solve the problem when seajs loads jquery and prompts $ is not a function_jquery

WBOY
WBOYOriginal
2016-05-16 15:35:271378browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn