[Vuejs]-How do you extract specific data from a for loop in vue.js instance on click event

0👍

I am giving some modifications need to work

Pass note with the event.

openNote() {
      this.$emit('open-note', this.note);
      console.log("clicked from NoteList");

 },

listen event at parent


 <note-list
          v-for="note in notes"
          :key="note.id"
          :note="note"
          @open-note="readNote" >
 </note-list>

declare a property in data object called currentNode: {}


 data() {
    return {
      editorIsOpen: false,
      readingNote: false,
      currentNode: {} // +====> add new property
      ....
}
}



modify readNote method

readNote(note) {
      this.currentNote = note;
      this.readingNote = !this.readingNote;
      document.querySelector('.readNoteButton').innerHTML="close note"
      document.querySelector('.readNoteButton2').innerHTML="close note"
      // alert('you clicked me!');
    },

Leave a comment