-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
38 lines (36 loc) · 1 KB
/
app.js
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
$('.container')
.append('<div id="app"></div>')
$('#app').reactive({
templateId: '#dinner-table-template',
config: {
data: {
dinnerPrice: 100,
tipPrice: 10,
},
actions: {
incrementDinner: function () {
this.dinnerPrice++;
},
decrementDinner: function () {
this.dinnerPrice--;
},
incrementTip: function () {
this.tipPrice++;
},
decrementTip: function () {
this.tipPrice--;
},
},
computed: {
total: function () {
const total = this.dinnerPrice + (this.dinnerPrice * this.tipPrice / 100);
return total.toLocaleString('pt-BR',
{ style: 'currency', currency: 'BRL' });
},
shouldInactiveButton: function () {
return this.tipPrice <= 0;
}
}
},
persist: true
});