小程序模板网

微信小程序删除处理

发布时间:2017-12-25 11:38 所属栏目:小程序开发教程

没有 confrim 那怎么实现这个效果呢 ?

 
 
 

没有 confrim 那怎么实现这个效果呢 
可以使用小程序里的模态框 
代码:

wxml:

 

		
  1. <a class="reply" wx:if="{{comment.uid==comment.login_uid}}" bindtap="del" data-cid="{{comment.c_id}}">删除</a>

js:

 

		
  1. del:function(e){
  2. var that = this;
  3. wx.showModal({
  4. title: '提示',
  5. content: '确定要删除吗?',
  6. success: function (sm) {
  7. if (sm.confirm) {
  8. // 用户点击了确定 可以调用删除方法了
  9. wx.request({
  10. url: 'https://m.*****.com/index.php/Home/Xiaoxxf/home_comment_del?c_id=' + e.currentTarget.dataset.cid, //删除房间评论
  11. data: '',
  12. header: {
  13. 'Content-Type': 'application/json'
  14. },
  15. method: 'GET',
  16. success: function (res) {
  17. console.log(res);
  18. wx.showToast({
  19. title: res.data, //数据返回提示,查看后台PHP
  20. icon: 'success',
  21. duration: 2000
  22. })
  23. /* 获取房间评论信息 -xzz 0714*/
  24. getList(that);
  25. },
  26. fail: function (res) { },
  27. complete: function (res) { },
  28. })
  29. } else if (sm.cancel) {
  30. }
  31. }
  32. })
  33. }

效果:

这样就实现js的confirm效果了。



易优小程序(企业版)+灵活api+前后代码开源 码云仓库:starfork
本文地址:https://www.eyoucms.com/wxmini/doc/course/18241.html 复制链接 如需定制请联系易优客服咨询:800182392 点击咨询
QQ在线咨询