seajs加載jquery時提示$ is not a function該怎麼解決

這篇文章主要介紹了seajs加載jquery時提示$ is not a function該怎麼解決的相關資料,須要的朋友能夠參考下

jquery1.7以上的都支持模塊化加載,只是jquery默認的是支持amd,不支持cmd。因此要用seajs加載jquery時,咱們須要稍微作下改動,須要把如下內容作下修改,具體修改方式以下:jquery

mvc

?
1
2
3
4
5
if ( typeof define === "function" && (define.amd)) {
   define( "jquery" , [], function () {
     return jQuery;
   });
}

改爲app

?
1
2
3
4
5
if ( typeof define === "function" && (define.amd || define.cmd)) {
   define( "jquery" , [], function () {
     return jQuery;
   });
}

模塊化

?
1
2
3
4
5
if ( typeof define === "function" ) {
   define( "jquery" , [], function () {
     return jQuery;
   });
}

經過以上代碼的修改就能夠成功解決seajs加載jquery時提示$ is not a function問題,但願對你們有所幫助。url

相關文章
相關標籤/搜索