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
Release: 2016-05-16 15:35:27
Original
1377 people have browsed it

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;
   });
 }
Copy after login

changed to

 if (typeof define === "function" && (define.amd || define.cmd)) {
   define( "jquery", [], function() {
     return jQuery;
   });
 }
Copy after login

or

 if (typeof define === "function") {
   define( "jquery", [], function() {
     return jQuery;
   });
 }
Copy after login

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.

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template