Skip to content

splice is not working as expected and ALWAYS removes last item in array no matter which index is given #4825

Closed
@kgrosvenor

Description

@kgrosvenor

This is my parent vue component which is repeats this child component

<v-feed-item v-for="(post, index) in posts" :post="post" :user="user" v-on:item-deleted="posts.splice(index, 1)"></v-feed-item>

in the feed item template component i'm using $emit function to access the v-on:item-deleted

posts.splice is causing the last item in the array to be removed, i've also tried calling a function similar to below example but exactly the same result, i can even console log and get the desired index that i would like to be removed. Is this a genuine bug? My template code in child item is pretty complex but i even tried making it absolutely minimal but still same result...

onDelete: function (item, index) {
                   var self = this;
                   let idx = self.posts.indexOf(item);
                   self.posts.splice(idx, 1);
           }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions