demo 结构:
config.js
require.config({ baseUrl: 'js/lib', paths: { 'jquery' : 'jquery-1.11.1.min', 'util' : 'util', 'bootstrap' : 'bootstrap.min', 'demo' : '../app/demo' }, shim: { 'util' : { exports : 'util', deps : ['bootstrap'] }, }});
自定义模块 demo.js
// 自定义模块(function(window) { var demo = {}; demo.message = function(msg, type){ require(['util'], function(u){ u.message(msg, '', type); }); } if (typeof define === "function" && define.amd) { define(function(){ return demo; }); } else { window.demo = demo; }})(window);
index.html
content
拓展:
(一)http://www.cnblogs.com/KeenLeung/p/6386434.html
(二)http://www.cnblogs.com/KeenLeung/p/6386468.html
(三)http://www.cnblogs.com/KeenLeung/p/6386559.html
============ end