forked from RubyLouvre/avalon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test4.html
53 lines (52 loc) · 1.32 KB
/
test4.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
<!DOCTYPE HTML>
<html id="html">
<head>
<meta charset="utf-8">
<title>测试用例-yuewang</title>
</head>
<body>
<div ms-controller="test">
<button ms-click="one">测试1</button>
<br>test0: {{test0}}
<br>test1: {{test1}}
<br>test2: {{test2}}
<br>使用异步后,无法按以前版本的预期顺序执行语句
<br>msg: {{msg}}
</div>
<script src="avalon.mobile.js"></script>
<script>
// 这里的逻辑是test2的数据来自test1,test1的数据来自test0
avalon.define("test", function(vm) {
vm.test0 = false;
vm.test1 = false;
vm.test2 = false;
vm.msg = '预期的结果是test0-test1-test2-,实际的结果是';
vm.$watch('test0', function(val) {
if (val) {
vm.msg += 'test0-';
console.log("11111111111111")
vm.test1 = true;//111111
console.log("-----------------")
if (vm.test2) {
console.log("666666666")
vm.msg = '这是预期的结果';
return;
}
console.log("9999999999999")
vm.msg += 'test2-';
}
});
vm.$watch('test1', function(val) {//222222222
if (val) {
vm.msg += 'test1-';
console.log("xxxxxxxxxxxxx")
vm.test2 = true;
}
});
vm.one = function() {
vm.test0 = true;
};
});
</script>
</body>
</html>