seajs加载jquery时提示$ is not a function该怎么解决
jquery1.7以上的都支持模块化加载,只是jquery默认的是支持amd,不支持cmd。所以要用seajs加载jquery时,我们需要稍微做下改动,需要把以下内容做下修改,具体修改方式如下:
把
if(typeofdefine==="function"&&(define.amd)){ define("jquery",[],function(){ returnjQuery; }); }
改成
if(typeofdefine==="function"&&(define.amd||define.cmd)){ define("jquery",[],function(){ returnjQuery; }); }
或
if(typeofdefine==="function"){ define("jquery",[],function(){ returnjQuery; }); }
通过以上代码的修改就可以成功解决seajs加载jquery时提示$isnotafunction问题,希望对大家有所帮助。