小程序删除id

//wxml

<view  wx:for="{{ispaltes}}" wx:for-index='key' wx:for-item='item'>
  <text>{{item}}</text>
  <view  bindtap="colse" id="{{key}}">

    <button>关闭</button>

  </view>
</view>
 
//js
data: {
  paltes:[],
  value:0
},
colse:function(e){
  var id = e.currentTarget.id//获取id
  let paltes = this.data.paltes;
  paltes.splice(id, 1); // 删除
  this.setData({
    paltes:paltes
  })
  // 数据存储里删除
  var onplates = wx.getStorageSync('plates') || []
  onplates.shift(id, 1)//删除
  wx.setStorageSync('plates', onplates)
}
 
 
 
// 加加减减
del:function(){
let value=this.data.value
if(value>0){
  value--
}
this.setData({
  value: value
})
},
add: function () {
let value = this.data.value
value++
this.setData({
  value: value
})
},
},

 

posted @ 2020-04-24 10:52  茗涵  阅读(275)  评论(0编辑  收藏  举报