Melchior.jsJavaScript 模块加载器
Melchior.js 是一个模式加载器,提供通过链式模块定义的API,让你可以远离那些长长的AMD定义和重复的模块名。它起步非常容易,定制方便,而且压缩版只有3KB。
在线演示
示例代码:
// create modulemelchiorjs.module('yourModule')// define dependencies.require('dependencyUno')
.require('dependencyDuo', 'duo')// define module body.body(function () { // `dependencyUno` is available here!
dependencyUno.doSomething(); // aliased `dependencyDuo` is available as `duo`!
duo.doSomething(); // return methods for other modules
return {
method: function () { ... },
anotherMethod: function () { ... }
};
});
配置:
melchiorjs.config({
paths: { 'jQuery': 'path/to/jquery', 'underscore': 'path/to/underscore', 'myModule': 'path/to/myModule'
}, // provide shim to non-melchior modules if needed
// declare globals returned by libraries and deps
shim: {
underscore: {
exports: '_'
}
}
});
支持的浏览器:
| 1+ ✔ | 2+ ✔ | 8+ ✔ | 10+ ✔ | 3+ ✔ |
评论
