沒有 confrim 那怎么實現這個效果呢 ?
沒有 confrim 那怎么實現這個效果呢
可以使用小程序里的模態框
代碼:
wxml:
<a class="reply" wx:if="{{comment.uid==comment.login_uid}}" bindtap="del" data-cid="{{comment.c_id}}">刪除</a>
js:
del:function(e){
var that = this;
wx.showModal({
title: '提示',
content: '確定要刪除嗎?',
success: function (sm) {
if (sm.confirm) {
// 用戶點擊了確定 可以調用刪除方法了
wx.request({
url: 'https://m.*****.com/index.php/Home/Xiaoxxf/home_comment_del?c_id=' + e.currentTarget.dataset.cid, //刪除房間評論
data: '',
header: {
'Content-Type': 'application/json'
},
method: 'GET',
success: function (res) {
console.log(res);
wx.showToast({
title: res.data, //數據返回提示,查看后臺PHP
icon: 'success',
duration: 2000
})
/* 獲取房間評論信息 -xzz 0714*/
getList(that);
},
fail: function (res) { },
complete: function (res) { },
})
} else if (sm.cancel) {
}
}
})
}
效果:
這樣就實現js的confirm效果了。