[Vuejs]-How do I get my delete button to delete one row of data?

0👍

Put button element inside the li tag and remove the native modifier and pass the index as a parameter to the deleteQuote method:

<li v-for="(person,index) in persons">
  <span v-for="value in person"> {{ value }} </span>
   <button @click="deleteQuote(index)">
      Delete
  </button>
</li>

the method should be defined with index as a parameter :

  methods: {
    deleteQuote: function(index) {
        this.persons.splice(index, 1);
    }
  }

Leave a comment