+
80
-

seaja加载jquery提示$不存在?

seaja加载jquery提示$不存在?

  seajs.use(['//repo.bfw.wiki/bfwrepo/js/jquery.17.js'],function($) {
            $(function () {
})
});

请问是什么问题?

网友回复

+
0
-

这是由于jquery不支持cmd加载方式导致的错误。

jquery1.7以上默认的是支持amd加载,不支持cmd加载。只需要稍微改下jquery,就可以让jquery支持seajs的加载。

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;
 });
}

我知道答案,我要回答