forked from RubyLouvre/avalon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex05if.html
47 lines (40 loc) · 1.37 KB
/
index05if.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
<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ms-if</title>
<script src="avalon.js"></script>
<style>
.active{
background: blueviolet;
}
</style>
<script>
var model = avalon.define('xxx', function(vm) {
vm.items = [
{url: '#123', text: 'menu 123', actived: true},
{url: '#124', text: 'menu 124', actived: false}
];
vm.bool = false
vm.click = function() {
alert(this.innerHTML)
}
vm.toggle = function() {
vm.bool = true;
model.items[1].actived = !model.items[1].actived
}
});
</script>
</head>
<body ms-controller="xxx">
<h3 style="text-align: center">ms-if</h3>
<ul class="nav" ms-each-el="items">
<li><a ms-attr-href="el.url">{{el.text}}</a></li>
<li ms-class="active:el.actived" ms-if="el.actived">
<div>再渲染一次{{el.text}}</div>
</li>
</ul>
<p><button type='button' ms-click='toggle'>点我</button></p>
<div ms-if='bool' ms-click='click' > 这个东西会被移除</div>
</body>
</html>