Using this method, the data source will be modified directly, and reassignment cannot be done, because it returns the deleted item, and often, what we need is the deleted source number object
Execute a sentence.
this.buy_list.splice(index,1)
not like this:
var a = this.buy_list.splice(index,1)
Definition and Usage
The splice() method adds/removes items to/from the array and returns the removed item.
Note: This method mutates the original array.
grammar
arrayObject.splice(index,howmany,item1,.....,itemX)
parameter | describe |
---|---|
index | Required. Integer specifying the position to add/remove items, use a negative number to specify the position from the end of the array. |
howmany | Required. The number of items to delete. If set to 0, the item will not be deleted. |
item1, ..., itemX | Optional. New item added to the array. |
return value
Types of | describe |
---|---|
Array | A new array containing the deleted items, if any. |