forked from seajs/seajs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cheatsheet.html
172 lines (132 loc) · 2.74 KB
/
cheatsheet.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8"/>
<title>速查手册 - SeaJS</title>
<link rel="stylesheet" href="assets/style.css"/>
<style>
h3 a {
float: right;
font-size: 16px;
position: relative;
top: 10px;
padding-right: 10px;
}
</style>
</head>
<body>
<div id="content">
<h1>
<a href="./"><span class="logo">SeaJS</span> <span class="byline">文档</span></a>
</h1>
<h2>速查手册</h2>
<h3 id="use">
seajs.use
<a href="bootstrap.html#load-module">载入模块</a>
</h3>
<pre>
seajs.use('./a');
seajs.use('./a', function(a) {
a.doSomething();
});
seajs.use(['./a', './b'], function(a, b) {
a.doSomething();
b.doSomething();
});
</pre>
<h3 id="config">
seajs.config
<a href="global-configuration.html">全局配置</a>
</h3>
<pre>
seajs.config({
base: 'path/to/jslib/',
alias: {
'app': 'path/to/app/'
},
charset: 'utf-8',
timeout: 20000,
debug: false
});
</pre>
<h3 id="define">
define
<a href="module-authoring-format.html">模块书写格式</a>
</h3>
<pre>
define(function(require, exports, module) {
// The module code goes here
});
</pre>
<h3 id="require">
require
<a href="module-authoring-format.html#require">require</a>
</h3>
<pre>
define(function(require) {
var $ = require('jquery');
var a = require('./a');
a.doSomething();
// snip...
});
</pre>
<h3 id="require-async">
require.async
<a href="module-authoring-format.html#require-async">require.async</a>
</h3>
<pre>
define(function(require, exports, module) {
require.async('./b', function(b) {
b.doSomething();
});
require.async(['./c', './d'], function(c, d) {
// do something
});
});
</pre>
<h3 id="exports">
exports
<a href="module-authoring-format.html#exports">exports</a>
</h3>
<pre>
define(function(require, exports) {
// snip...
exports.name = 'a';
exports.doSomething = function() {};
});
</pre>
<h3 id="module-exports">
module.exports
<a href="module-authoring-format.html#module-exports">module.exports</a>
</h3>
<pre>
define(function(require, exports, module) {
// snip...
module.exports = {
name: 'a',
doSomething: function() {};
};
});
</pre>
<h3 id="no-conflict">
seajs.noConflict
<a href="global-configuration.html#no-conflict">noConflict</a>
</h3>
<pre>
var myLoader = seajs.noConflict(true);
myLoader.use('./main');
/* main.js */
myLoader.define(function(require, exports, module) {
// snip...
});
</pre>
<p class="next-page">
下一节:<a href="recommended-modules.html">模块精选</a>
</p>
<p id="copyright">
© 2011 - 2022 seajs.com
</p>
</div>
<script src="../build/sea.js" data-main="./assets/init"></script>
</body>
</html>