Closed mythicalprogrammer closed 6 years ago
It should be
computed: { selectedNote() { if(!this.notes.length) { this.addNote() } return this.notes.find(note => note.id === this.selectedId) } }
If the notes array is empty then the selectedNote() function returns undefined and vuejs won't render. The ifcondition was added.
notes
selectedNote()
if
Nevermind, I should have read ahead sorry.
It should be
If the
notes
array is empty then theselectedNote()
function returns undefined and vuejs won't render. Theif
condition was added.