-
Notifications
You must be signed in to change notification settings - Fork 221
/
avalon.mmPromise.ex4.html
74 lines (69 loc) · 2.6 KB
/
avalon.mmPromise.ex4.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
<!DOCTYPE html>
<html>
<head>
<title>Promise组件</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<link type="text/css" rel="stylesheet" href="../style/avalon.doc.css">
<script src="../avalon.js">
</script>
<script src="../highlight/shCore.js">
</script>
<script>
require(["mmPromise/mmPromise", "domReady!"], function() {
var _resolve, _reject
var originalPromise = new Promise(function(resolve, reject) {
_resolve = resolve
_reject = reject
});
var promise = new Promise(function(resolve) {
resolve(originalPromise);
});
promise.then(function(value) {
vmodel.array.push("跑到这里来了");
}, function(reason) {
vmodel.array.push(reason)
vmodel.array.push(reason === "original reason");
});
var vmodel = avalon.define("test", function(vm) {
vm.click = function() {
_reject("original reason")
}
vm.array = ["准备开始"]
})
avalon.scan()
})
</script>
</head>
<body ms-controller="test">
<ul>
<li ms-repeat="array">{{el}}</li>
</ul>
<p><button ms-click="click" type="button">点我开始</button></p>
<pre class="brush:javascript;gutter:false;toolbar:false;">
require(["mmPromise/mmPromise", "ready!"], function() {
var _resolve, _reject
var originalPromise = new Promise(function(resolve, reject) {
_resolve = resolve
_reject = reject
});
var promise = new Promise(function(resolve) {
resolve(originalPromise);
});
promise.then(function(value) {
vmodel.array.push("跑到这里来了");
}, function(reason) {
vmodel.array.push(reason)
vmodel.array.push(reason === "original reason");
});
var vmodel = avalon.define("test", function(vm) {
vm.click = function() {
_reject("original reason")
}
vm.array = ["准备开始"]
})
avalon.scan()
})
</pre>
</body>
</html>