Gary的影响力 2016-09-19
官网:http://seajs.org/docs/
文档:http://www.zhangxinxu.com/sp/seajs/docs/zh-cn/deployment.html
文档:http://yslove.net/seajs/
整合顺序:
1、jquery
2、sea.js
3、初始化
seajs.config({
alias: {
"jquery": "js/jquery.js"
}
});4、模块编写
define(function(require, exports, module) {
var $ = require('jquery');
exports.init = function(){
alert(123);
$('body').append('hello');
};
});5、出错了:$isnotafunction
6、原因:jquery1.7以上的都支持模块化加载,只是jquery默认的是支持amd,不支持cmd。所以要用seajs加载jquery时,我们需要稍微做下改动,需要把以下内容做下修改,具体修改方式如下:
if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
define( "jquery", [], function () { return jQuery; } );
}修改为:
if (typeof define === "function" && (define.amd || define.cmd)) {
define( "jquery", [], function() {
return jQuery;
});
}