-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
35 lines (34 loc) · 1020 Bytes
/
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
const app = new Vue({
el: '#app',
data: {
titulo : 'Clientes del GYM',
tareas: [],
nuevaTarea:""
},
methods: {
agregarTarea : function(){
this.tareas.push({
nombre:this.nuevaTarea,
estado: false
});
this.nuevaTarea='';
localStorage.setItem('gym-vue', JSON.stringify(this.tareas));
},
editarTarea : function(index){
this.tareas[index].estado=true;
localStorage.setItem('gym-vue', JSON.stringify(this.tareas));
},
eliminar : function(index){
this.tareas.splice(index,1)
localStorage.setItem('gym-vue', JSON.stringify(this.tareas));
}
},
created : function(){
let datosDB =JSON.parse(localStorage.getItem('gym-vue'));
if(datosDB === null){
this.tareas=[];
}else{
this.tareas = datosDB;
}
}
})