-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
61 lines (60 loc) · 2.09 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
<html>
<head>
<title>VueJS practices</title>
<script type="text/javascript" src="js/vue.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css" />
</head>
<body>
<div id="raiz" v-on:mousemove="getCoordinates">
{{ greetingMessage }}
<a :href="linkcito" target="_blank">My Link</a>
<input type="text" id="nuevolink" v-on:input="changeLink" />
<button type="button" @click="increase">Counter increase</button>
<h3>Normal counter {{getCounter()}}</h3>
<h3>Enhanced counter {{getComputedCounter}}</h3>
<span>{{x + ' ' + y}}</span>
</div>
<script>
new Vue({
el: "#raiz",
data: {
greetingMessage: "Hello world",
linkcito: "",
count: 0,
x: 0,
y: 0
},
watch: {
count: function() {
let vm = this;
setTimeout(function() {
vm.count = 0;
}, 3000);
}
},
computed: {
getComputedCounter() {
console.log("getComputedCounter executed");
return this.count;
}
},
methods: {
changeLink: function(evt) {
this.linkcito = "https://" + evt.target.value
},
increase: function() {
this.count = this.count + 1;
},
getCounter() {
console.log("getCounter executed");
return this.count;
},
getCoordinates: function(evt) {
this.x = evt.clientX;
this.y = evt.clientY;
}
}
});
</script>
</body>
</html>