delspecification: function(e){
var sid = e.currentTarget.dataset.id
var s = this.data.specifications
var slist = []
var j = 1;
for(var i=0;i<s.length;i++){
var map = s[i]
map._id = j;
if(sid!=s[i]._id){
slist.push(map)
j++
}
}
this.setData({specifications:slist})
}
z
这是for循环的json值:
我传进去的“sid”值是“3”
当i=4时,json却变了,后面的ID全部变成了3:
var map = Object.assign({}, s[i])