收藏
回答

修改数组某项key的value值后,打印原数组 , 每项对应的key的value值都跟着改变了?

修改数组某项key的value值后,页面渲染是正确的, 但打印这个数组 , 每项对应的key的value值都跟着改变了,大神们,有遇到过这种问题吗 怎么解决??? 怎么让打印数组和改变的值对应起来??? 很头疼...

selectMajor(e){
        var that=this
        if(that.data.stype==1){
            for(var i=0;i<that.data.selectTeeth.length;i++){
                if(i==that.data.zYindex){
                    let temp = 'selectTeeth[' + that.data.zYindex +'].zhuanye'  
                    that.setData({
                        [temp]:e.currentTarget.dataset.name,
                    })
                }
            }
        }else{
            for(var i=0;i<that.data.htmlArr.length;i++){
                if(i==that.data.zYindex){
                    let temp = 'htmlArr[' + that.data.zYindex +'].zhuanye'  
                    that.setData({
                        [temp]:e.currentTarget.dataset.name,
                    })
                }
            }
            console.log(that.data.htmlArr)  //打印数组
        }
        that.setData({
            showMask: false
        })
    },
回答关注问题邀请回答
收藏
登录 后发表内容