這篇文章主要介紹了seajs加載jquery時提示$ is not a function該怎么解決的相關資料,需要的朋友可以參考下
jquery1.7以上的都支持模塊化加載,只是jquery默認的是支持amd,不支持cmd。所以要用seajs加載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;
- });
- }
通過以上代碼的修改就可以成功解決seajs加載jquery時提示$ is not a function問題,希望對大家有所幫助。
新聞熱點
疑難解答
圖片精選