-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvueSy.html
70 lines (64 loc) · 1.72 KB
/
vueSy.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
<html>
<head>
<title></title>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="vue.js"></script>
</head>
<body>
<div id="app">
{{ message | add5 | add1 }}<br/> {{t1}}
<p v-if="seen">现在你看到我了</p>
<ul>
<li v-for="todo in todos">
{{ todo.text | add1 }}
</li>
</ul>
<button v-on:click="reverseMessage">逆转消息</button>
<input v-model="message">
<ul>
<wfj v-for="item in todos" v-bind:todo="item"></wfj>
</ul>
</div>
</body>
<script>
Vue.component('wfj', {
// todo-item 组件现在接受一个
// "prop",类似于一个自定义属性
// 这个属性名为 todo。
props: ['todo'],
template: '<li>这是个待办项{{todo.text}}</li>'
// template: '<li>{{ todo.text }}</li>'
})
var app = new Vue({
el: '#app',
data: {
message: 'hello world!',
t1: 'wfjuan',
seen: false,
todos: [{
text: '学习 JavaScript'
}, {
text: '学习 Vue'
}, {
text: '整个牛项目'
}]
},
methods: {
reverseMessage: function() {
this.seen = !this.seen;
this.message = this.message.split('').reverse().join('');
}
},
filters: {
add5: function(value) {
if (!value) return 0;
value = value + 5;
return value;
},
add1: function(value) {
return value + ':';
},
}
});
</script>
</html>