Typescript Vuejs从列表中拼接多个项目

Typescript Vuejs从列表中拼接多个项目,typescript,vue.js,vuejs2,Typescript,Vue.js,Vuejs2,我的应用程序中有多个删除选项,它确实会从数据库中删除项目,但问题是在前端。不知何故,我无法从列表中拼接正确的项目 演示 如您所见,我删除了列表中的项目2和3,但项目1已从列表中删除 代码 评论 toggleSelection(row) { const myIds = this.multipleSelection.map((row) => row.id); this.$confirm('This will permanently delete the items. Cont

我的应用程序中有多个删除选项,它确实会从数据库中删除项目,但问题是在前端。不知何故,我无法从列表中拼接正确的项目

演示

如您所见,我删除了列表中的项目
2和3
,但项目
1
已从列表中删除

代码
评论

toggleSelection(row) {
    const myIds = this.multipleSelection.map((row) => row.id);
    this.$confirm('This will permanently delete the items. Continue?', 'Warning', {
        confirmButtonText: 'Yes',
        cancelButtonText: 'Cancel',
        type: 'warning',
        center: true
    }).then(() => {
        axios.post('/api/wishlist/destroyMultiple/', {ids: myIds}).then((res) => {
            this.$message({
                showClose: true,
                type: 'success',
                message: res.data.success
            });
            this.wishlist.splice(this.wishlist.indexOf(row), 1)  // issue comes from here
        })
        .catch((err) => {
            this.$message({
                showClose: true,
                type: 'info',
                message: err
            });
        });
    }).catch(() => {
        this.$message({
            showClose: true,
            type: 'info',
            message: 'Delete canceled'
        });
    });
},

有什么想法吗?

那么,您似乎正在尝试访问
未定义的索引,并将其拼接到此处:

this.wishlist.splice(this.wishlist.indexOf(row), 1) 
上面的代码将删除数组的最后一个元素。 让我们试试这个:

this.multipleSelection.forEach(x => this.wishlist.splice(this.wishlist.indexOf(x),1))

切换选择
功能的输入值(
)是多少?一排?还是所有选定行?还是什么?@MuhammadVakili
未定义
@MuhammadVakili此函数的
引用错误:未定义a