wx: wx.showModal callback call a custom method

First, call the custom method in the callback function:

Callback function can not directly use this, need to be defined on the outside  var that = this and that. Custom method. as follows:

  // Delete 
  The onDelete: function (E) {
     var that = the this ; 
    wx.showModal ({ 
      title: ' prompt ' , 
      : Content ' ? Sure you want to delete ' , 
      Success: function (RES) { 
        IF (res.confirm) {
           that .onEdit (E); 
        } 
      } 
    }) 
  } 
  // edit 
  OnEdit: function (E) { 
    the console.log ( ' edit ' ); 
  },

Second, the frame shells Detailed wx.showToast, wx.showModal, wx.showActionSheet, modal control and interpretation of the acquired input value input box

(1)、wx.showToast

  wx.showToast ({ 
    title: ' Failed ' , // prompt text 
    DURATION: 2000 , // display duration 
    mask: to true , // whether transparency mask layer to prevent penetration of touch, default: to false   
    icon: ' Success ' , / / icon support "success", "loading"   
    success: function () {}, // interface calls successfully 
    fail: function () {},   // interface calls the failure callback function   
    Complete: function () {} // Interface call the end of the callback function   
  })

(2)、wx.showModal

  wx.showModal ({ 
    title: ' Delete picture ' , 
    Content: ' you sure you want to delete this picture? ' , 
    showCancel: to true , // whether to display the Cancel button 
    CancelText: " No " , // default is "Cancel" 
    cancelColor: ' Skyblue ' , // cancel text color 
    confirmText: " yes " , // default is "OK" 
    confirmColor: ' Skyblue ' , // determine the color of the text 
    success: function (res) {
      IF (res.cancel) {
         // click Cancel, playing hide block default 
      } the else {
         // click OK 
        temp.splice (index, . 1 ), 
          that.setData ({ 
            tempFilePaths: TEMP, 
          }) 
      } 
    }, 
    Fail: function ( RES) {}, // interface calls the failure callback function 
    Complete: function (RES) {}, // call the end of the interface callback function (call succeeds, the failure will be executed) 
  })

(3), wx.showActionSheet

  wx.showActionSheet ({ 
    the itemList: [ ' column 1 ' , ' Column 2 ' , ' Column 3 ' ], // list of items displayed 
    Success: function (RES) { // list item clicked res.tapIndex 
      console.log ( " clicked list item: " + that [res.tapIndex]) 
    }, 
    Fail: function (RES) {}, 
    Complete: function (RES) {} 
  })

Guess you like

Origin www.cnblogs.com/xubao/p/12151687.html