m7vm7v
2 years ago
1736
11
Vue

How to remove an item from a list with given ID in VueJS

Posted 2 years ago by m7vm7v

Hi, I need to delete an item in list in VueJS when I have the id

My list looks like:

list : [
    {id: 5, name: Item1},
    {id: 10, name: Item2}
]

I have a method

deleteItem(itemID){}

How can I delete an item from 'list' where id = itemID

I know it shoul look something like:

this.questions.splice(id, data);

But not sure how exactly. Thanks for your help.

Please sign in or create an account to participate in this conversation.