requirejs.config({
//默认情况下模块所在目录为js/lib
baseUrl: './',
//当模块id前缀为app时,他便由js/app加载模块文件
//这里设置的路径是相对与baseUrl的,不要包含.js
paths: {
'lodash': 'lodash',
'postal': 'postal'
},
shim: {
'postal': ['lodash']
}
});
requirejs(['lodash','postal'],
function (_,postal) {
var channel = postal.channel();
// subscribe to 'name.change' topics
var subscription = channel.subscribe( "name.change", function( data ) {
console.log("name.changed:"+data.name);
} );
// And someone publishes a name change:
channel.publish( "name.change", { name: "Dr. Who" } );
});