效果圖如下:

核心代碼如下:
delType:function(e){ var typeId = e.currentTarget.dataset['id']; console.log("delete:"+typeId) wx.showModal({ title: '提示', content: '確認(rèn)要?jiǎng)h除該支出類型?', success: function (res) { if (res.confirm) { console.log('用戶點(diǎn)擊確定') 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) { //訪問(wèn)正常 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('用戶點(diǎn)擊取消') } } })}wxml代碼如下:
<text bindtap='delType' data-id="{{item.typeId}}">刪除</text>data-id相當(dāng)于綁定對(duì)應(yīng)的值,比方說(shuō)你是根據(jù)id來(lái)刪除對(duì)應(yīng)的數(shù)據(jù)。
bindtap,即綁定事件。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持錯(cuò)新站長(zhǎng)站。
新聞熱點(diǎn)
疑難解答
圖片精選