微信小程序: 数组添加push()、删除splice()操作

1、数组.push(对象)

直接向数组末尾追加新的元素(不会去重)

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

 2、数组.splice删除元素

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): 是从index开始删除1个元素 , 并返回所删除的元素

猜你喜欢

转载自blog.csdn.net/Ghjkku/article/details/128890630