如何在微信小程序中實現確認框?相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。
核心代碼如下:
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: '系統異常',
fail
})
setTimeout(function () {
wx.hideLoading()
}, 2000)
}
}
})
} else if (res.cancel) {
console.log('用戶點擊取消')
}
}
})
}wxml代碼如下:
<text bindtap='delType' data-id="{{item.typeId}}">刪除</text>看完上述內容,你們掌握如何在微信小程序中實現確認框的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。