I have a problem with Vue js:
I try to do something like a list of notes.
I have a json array where all the notes will be saved and a json where the note that the person wants to create is saved. But the problem is:
After doing a push to the json array, it is added perfectly, but after modifying the value in the json the json array is automatically modified.
I can not modify the json without modifying the value in the array.
PD: the method that the push does is activated when I click on a button
I will leave here the most relevant code, if you need more information I will gladly provide it.
el: '#app',
data: {
hasError: 0,
typeError: '',
noteSelected: null,
note: {
title: '',
content: '',
tags: [],
tagsString: ''
},
notes: [{
title: 'titulo de una nota',
content: 'contenido de una nota',
tags: ['nota', 'contenido'],
tagsString: ''
}]
},
methods:{
newNote: function() {
if (this.validate() === true && this.noteSelected === null) {
this.addTags();
this.noteSelected = this.note;
this.notes.push(noteSelected);
}
},
}