seajs加载jquery提示$ is not a function

时间:2022-04-11 11:46:51

jquery1.7以上的都支持模块化加载,只是jquery默认的是支持amd,不支持cmd。所以要用seajs加载jquery,需要稍微改下jquery

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

改成

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

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

就可以了