-
Notifications
You must be signed in to change notification settings - Fork 3
Quick Start
Daniel Yang edited this page Feb 3, 2014
·
6 revisions
小矮人加载器(webkit-dwarf)用法和requirejs和seajs非常相近,下面是一个简单的例子:
- index.html:
<!DOCTYPE html>
<html>
<head></head>
<body>
<!-- 加载模块管理器 -->
<script type="text/javascript" src="https://raw.github.com/miniflycn/webkit-dwarf/master/dist/dwarf.min.js"></script>
<script>
// 加载依赖./js/ui.js
require(['./js/ui'], function () {
// 同步获取./js/ui.js的exports
var ui = require('./js/ui');
// 省略很多行
});
</script>
</body>
</html>
- js/ui.js:
// 定义
define('./ui', function (require, exports) {
exports.init = function () {
console.log('module init');
};
});