鍍金池/ 問(wèn)答/HTML/ vue用的餓了么組件,刪除出現(xiàn){__ob__: Observer}

vue用的餓了么組件,刪除出現(xiàn){__ob__: Observer}

clipboard.png

        deleteProduct(idx, rows,id){
                this.$confirm('是否刪除該條記錄?', {
                    confirmButtonText: '確定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios({
                        method: 'post',
                        url: '/product/delProductById',
                        headers: {
                            'Content-Type': 'application/json; charset=UTF-8',
                        },
                        data:{
                            id:id
                        }
                    }).then((response) => {
                        console.log(response)
                        if (response.data.resultInfo.type===1){
                            this.$message({
                                type: 'success',
                                message: '刪除成功!'
                            });
                            console.log(typeof rows)
                            console.log(rows)
                            rows.splice(idx, 1)
                        }else{
                            this.$message({
                                type: 'info',
                                message: '刪除失敗!'
                            });
                        }
                    }).catch((error) => {
                        console.log(error);
                        this.$message({
                            type: 'info',
                            message: '刪除失敗!'
                        });
                    })

由于console.log(rows)是{__ob__: Observer},會(huì)報(bào).splice is not a function的 錯(cuò),搜了下說(shuō)是異步的問(wèn)題。如何解決呢?

回答
編輯回答
柚稚

多虧有人提醒,確實(shí)是數(shù)據(jù)的問(wèn)題,數(shù)據(jù)是個(gè)對(duì)象 ,不是數(shù)組。。。

2017年9月18日 18:53
編輯回答
莫小染

請(qǐng)問(wèn)答主解決這個(gè)問(wèn)題了嗎,我想要數(shù)組,但是總是打出帶有observer的對(duì)象

2018年7月7日 02:52