zoukankan      html  css  js  c++  java
  • 微信小程序:删除时提示是否删除

    代码如下:

    wx.showModal({
          title: '提示',
          content: '确定要删除吗?',
          success: function (sm) {
            if (sm.confirm) {
                // 用户点击了确定 可以调用删除方法了
              } else if (sm.cancel) {
                console.log('用户点击取消')
              }
            }
    })

    项目中使用:

    deleteById(e) {
          console.log(e);
          this.QueryParam.baseId = e.currentTarget.dataset.id
          var that = this;
          wx.showModal({
            title: '提示',
            content: '确定要删除吗?',
            success: function (sm) {
              if (sm.confirm) {
                  // 用户点击了确定 可以调用删除方法了
                  request.postParam("/api/baseInfo/deleteBaseInfo",that.QueryParam,function(res){
                      console.log(res)
                      if(res.data.success){
                        wx.showToast({
                          title: "删除成功",
                          icon: 'none',
                          duration: 2000
                        })
                        that.getList(true);
                      }else{
                        wx.showToast({
                          title: "删除失败",
                          icon: 'none',
                          duration: 2000
                        })
                      }
                  });
                } else if (sm.cancel) {
                  console.log('用户点击取消')
                }
              }
            }) 
    },

    注意:var that = this;放在外面

  • 相关阅读:
    hello word
    HDU 1006 Tick and Tick
    HDU 1005 Number Sequence
    HDU 1004 Let the Balloon Rise
    HDU 1003 Max Sum
    HDU 1002 A + B Problem II
    HDU 1001 Sum Problem
    HDU 1000 A + B Problem
    POJ 2253 Frogger
    POJ 2387 Til the Cows Come Home
  • 原文地址:https://www.cnblogs.com/zwh0910/p/14244830.html
Copyright © 2011-2022 走看看