WeChat applet: array add push(), delete splice() operation

1. Array.push(object)

Append new elements directly to the end of the array (without deduplication)

//this.productTemporary=[]
this.productTemporary.push(e);

 2. Array .splice deletes elements

deleteBtn: function(event) {
    let index = event.currentTarget.dataset.index
    this.data.godness.splice(index, 1)
    this.setData({
      godness: this.data.godness
    })
  }

array.splice(index, 1): deletes 1 element from index  , and returns the deleted element

Guess you like

Origin blog.csdn.net/Ghjkku/article/details/128890630