我有两个数组一个WaitPayLists是全部数据,selectList被选中的数据,初始化两个数据一样,但是操作过程中selectList会被改变,WaitPayLists数据是不会变的,但是我用splice和push操作selectList的时候WaitPayLists的数据也会跟着自动增加或减少,我没有任何一个地方操作WaitPayLists增加一条或者减少一条数据,但是操作selectList数组时他就会自动增加和减少:下面是操作的代码:let that = this
let isPay = params.detail.value.length == 0 ? false : true
let selectList = that.data.selectList
if (isPay) {
selectList.push(params.currentTarget.dataset.item)
that.setData({
totalAmount: that.data.totalAmount + params.currentTarget.dataset.cash
})
if (selectList.length == that.data.WaitPayLists.length)
that.setData({
isAll: true
})
}
else {
for (let index = 0; index < selectList.length; index++) {
if (selectList[index].BillIndex == params.currentTarget.dataset.item.BillIndex) {
selectList.splice(index, 1)
break
}
}
that.setData({
totalAmount: that.data.totalAmount - params.currentTarget.dataset.cash,
isAll: false,
selectList: selectList
})
}