-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
111 lines (93 loc) · 3.13 KB
/
index.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie-edge">
<title>Document</title>
<style>
.text-red {
color:red;
}
.text-green {
color:green;
}
</style>
</head>
<body>
<div id="app">
<input v-model="message">
<input v-bind:value="message" v-on:input="message = $event.target.value">
{{message}}
<div>
<input v-model="loginForm.username" >
<input v-model="loginForm.password" >
<button v-on:click="submitForm">Submit</button>
</div>
<p>
{{filterList}}
</p>
<p>
<button v-on:click="show = !show">Toggle</button>
<span v-if="user">
{{user.name}}
</span>
</p>
<p v-if="show">
<span v-for="(item, index) in list">
<span v-bind:class="{'text-red' : item.color === 'red', 'text-green': item.color === 'green'}">
{{index + 1}}. {{item.name}},
</span>
</span>
</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
message: "Hello World",
loginForm: {
username: "",
password: ""
},
list: [
{name:"a - foo", color: 'red'},
{name:"a - john", color: 'red'},
{name:"b - doe", color: 'green'}
],
show: true,
user:null
},
created(){
console.log("Component Created")
},
beforeDestroy(){
console.log("Component Destroyed")
},
methods: {
submitForm() {
console.log("Submitting login form", this.loginForm)
var callLog = () => {
this.log(this.formInfo)
}
callLog();
},
log(v) {
console.log(v);
}
},
computed: {
formInfo: function() {
return this.loginForm.username + " " + this.loginForm.password;
},
filterList: function() {
return this.list.filter(x => {
return x.name.indexOf("a") === 0
})
}
}
})
</script>
</body>
</html>