-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
36 lines (36 loc) · 873 Bytes
/
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
<!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>Watch the input value</title>
</head>
<body>
<div id="app">
<input type="text" v-model="inputValue">
<p>Five seconds ago value was
<u>{{ oldInputValue }}</u>
</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script>
new Vue({
el: '#app',
data: {
inputValue: 'initial value',
oldInputValue: ''
},
watch: {
inputValue(val, oldVal) {
// val = this.inputValue
let newValue = this.inputValue;
setTimeout(() => {
this.oldInputValue = newValue
}, 5000)
}
}
})
</script>
</body>
</html>