forked from nuysoft/Mock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmock-kissy.html
57 lines (57 loc) · 1.45 KB
/
mock-kissy.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Mock</title>
<link href="assets/bootstrap/css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="http://a.tbcdn.cn/s/kissy/1.3.0/seed.js"></script>
<!-- <script src="../node_modules/kissy/build/seed-min.js"></script> -->
<script src="../dist/mock.js"></script>
</head>
<body>
<div class="container">
<h1>Mock 测试 - KISSY</h1>
<h2>1. 设置模拟数据</h2>
<pre id="data">
Mock.mock('foo.json', {
'list|3-5':[{
'id|+1': 1,
'name': '@First @Last'
}]
});
Mock.mock('bar.json', {
'list|3-5':[{
'id|+1': 100,
'email': '@EMAIL'
}]
});</pre>
<h2>2. 发送请求</h2>
<pre id="send">
KISSY.use(['components/mock/index', 'core'], function(S, Mock, Core){
var $ = S.all;
KISSY.io({
url:'foo.json',
success: function(data){
$('#foo').append(S.JSON.stringify(data, null, 4))
}
})
KISSY.io({
url:'bar.json',
success: function(data){
$('#bar').append(S.JSON.stringify(data, null, 4))
}
})
});</pre>
<h2>3. 响应数据</h2>
<pre id="foo"></pre>
<pre id="bar"></pre>
</div>
<script type="text/javascript">
KISSY.use('core', function(S, Core) {
var $ = S.all;
eval( $('#data').text() )
eval( $('#send').text() )
})
</script>
</body>
</html>