-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04.1computedProperty.js
More file actions
38 lines (37 loc) · 864 Bytes
/
Copy path04.1computedProperty.js
File metadata and controls
38 lines (37 loc) · 864 Bytes
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
new Vue({
el: '#app',
data: {
counter:0,
counter2:0,
counter3:0,
secondCounter3:6,
result:''
},
// Computed es cuando es como una propiedad, es lo mismo pero no necesita ()
computed: {
output: function() {
console.log('Computed');
return this.counter3 > 5 ? 'Greater 5' : 'Smaller 5';
}
},
methods: {
// Option 1
increase: function(){
this.counter ++;
this.result = this.counter > 5 ? 'Greater 5' : 'Smaller 5'
},
decrease: function(){
this.counter --;
this.result = this.counter > 5 ? 'Greater 5' : 'Smaller 5'
},
// Option 2
result2: function(){
return this.counter2 > 5 ? 'Greater 5' : 'Smaller 5'
},
// Option 3
result3: function(){
console.log('Method');
return this.counter3 > 5 ? 'Greater 5' : 'Smaller 5'
}
}
});