风景,因走过而美丽。命运,因努力而精彩。南国园内看夭红,溪畔临风血艳浓。如果回到年少时光,那间学堂,我愿依靠在你身旁,陪你欣赏古人的诗章,往后的夕阳。
效果图如下:
核心代码如下:
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>
data-id相当于绑定对应的值,比方说你是根据id来删除对应的数据。
bindtap,即绑定事件。
到此这篇关于微信小程序 确认框的实现(附代码)就介绍到这了。那时,春天只有三分熟,我在梦中独自行走。小舟上,一名黑衣人,于水面,种植鸢尾花。宣称,灰飞之日,那时我灵魂的睡榻。更多相关微信小程序 确认框的实现(附代码)内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!