[Vuejs]-Vue.js : removing item from list after added a new item caused a bug

0๐Ÿ‘

โœ…

If I were you, I would try the following:

remove(line) {
    axios.delete(domain + 'line/' + line._id)
    .then(res => {
        let index = this.lineList.indexOf(line)
        this.lineList.splice(index, 1);
    })
    .catch(err => {
        console.log(error);
    });
}

With this, you are sure that you have the correct index for the item at the moment that you want to delete it thanks to let index = this.lineList.indexOf(line)

Leave a comment