.js
Use arr.splice (id, 1) Delete
// 删除数组中指定下标
dele_time: function (e) {
console.log('删除')
console.log(e.currentTarget.id)
var id = e.currentTarget.id;
var arr= this.data.arr;
arr.splice(id,1)
console.log(duan)
this.setData({
arr: arr,
})
},
Spread
JavaScript splice () method
Definition and Usage
splice () method to add / remove items from the array to /, then return items are deleted.
Note: This method changes the original array.
grammar
arrayObject.splice(index,howmany,item1,.....,itemX)
Explanation
splice () method can remove zero or more elements from the beginning of the index, and to replace those removed element with one or more values of the parameters declared in the list.
If you remove an element from arrayObject, then it returns an array containing the elements to be deleted.