-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06-main.js
45 lines (45 loc) · 1.17 KB
/
06-main.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
38
39
40
41
42
43
44
45
new Vue({
el: 'main',
data: {
mensaje: 'Hola Mundo :) !',
nuevaTarea: null,
tareas: [{
titulo: 'Aprender Vue.js',
prioridad: true,
antiguedad: 23
},
{
titulo: 'Aprender ES6',
prioridad: false,
antiguedad: 135
},
{
titulo: 'Publicar algo todos los días',
prioridad: true,
antiguedad: 378
},
]
},
methods: {
agregarTarea() {
// this, hace referencia a la instancia Vue
this.tareas.unshift({
titulo: this.nuevaTarea,
prioridad: false,
antiguedad: 0,
});
this.nuevaTarea = null;
},
},
computed: {
tareasConPrioridad() {
return this.tareas.filter((tarea) => tarea.prioridad);
},
mensajeAlReves() {
return this.mensaje.split('').reverse().join('');
},
tareasPorAntiguedad() {
return this.tareas.sort((a, b) => b.antiguedad - a.antiguedad);
}
}
});