时间:2021-07-01 10:21:17 帮助过:4人阅读
本文实例为大家分享了小程序列表删除功能的具体代码,供大家参考,具体内容如下
wml文件:
<!-- 删除 --> <view class="delete" bindtap="deleteaddress" data-id="{{ item.id }}">删除</view>
js文件:
deleteaddress(e){ let that = this; console.log(e); let deldeid = e.currentTarget.dataset.id; let allDatas = that.data.allData; let newallData = []; for (var i in allDatas) { var item = allDatas[i]; if (item.id != deldeid) { newallData.push(item); } } console.log(newallData) wx.showModal({ 'content': '确认删除该地址信息吗?', 'cancelColor': '#0076FF', 'confirmColor': '#0076FF', success: function (res) { if (res.confirm) { console.log('用户点击确定') let url = getApp().Api_url + '/receiver/delete'; requestd._post(url, { receiverId: e.currentTarget.dataset.id }, function (res2) { console.log(res2); if( res2.data.status == 1 ){ that.setData({ allData: newallData }); }else{ wx.showModal({ 'showCancel': false, 'content': res2.data.message, 'confirmColor': '#0076FF' }) } }, function (res2) { }) } else if (res.cancel) { console.log('用户点击取消') } } }) }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。