效果圖如下:

核心代碼如下:
delType:function(e){ var typeId = e.currentTarget.dataset['id']; console.log("delete:"+typeId) wx.showModal({ title: '提示', content: '確認要刪除該支出類型?', success: function (res) { if (res.confirm) { console.log('用戶點擊確定') wx.request({ url: getApp().globalData.urlPath + "spendingType/delete", method: "POST", data: { typeId: typeId }, header: { "Content-Type": "application/x-www-form-urlencoded" }, success: function (res) { console.log(res.data.code); if (res.statusCode == 200) { //訪問正常 if (res.data.code == "000000") { wx.showToast({ title: "刪除成功,返回支出類型列表", icon: 'success', duration: 3000, success: function () { wx.navigateTo({ url: '../type/type' }) } }) } } else { wx.showLoading({ title: '系統(tǒng)異常', fail }) setTimeout(function () { wx.hideLoading() }, 2000) } } }) } else if (res.cancel) { console.log('用戶點擊取消') } } })}wxml代碼如下:
<text bindtap='delType' data-id="{{item.typeId}}">刪除</text>data-id相當于綁定對應的值,比方說你是根據(jù)id來刪除對應的數(shù)據(jù)。
bindtap,即綁定事件。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點
疑難解答