[Vuejs]-How to properly splice array item by id

1👍

There is quite a bit of unusual code in the example, so I may be missing something, but couldn’t you just pass the item to the method.

<p
  v-if="item.popUpTypeType === 'danger'"
  class="closing-x" 
  @click="closeMessage(item)"
>X</p>

and then

closeMessage(item) {
  const index = this.array.indexOf(item);
  if (index >= 0) this.array.splice(index, 1)
},

Leave a comment