Skip to content

Interaction

hideloading

TIP

The API usage is as follows: wx.hideLoading(Object object)

  • Functional description: Hide loading prompt box.
  • Parameters and descriptions: Object object
PropertiesTypeDefault valueRequiredDescription
noConflictbooleanfalseNoCurrently toast and loading related interfaces can be mixed with each other. This parameter can be used to cancel the mixed features
successFunction-NoCallback function for successful interface call
failFunction-NoCallback function for failed interface call
completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)

hideToast

TIP

The API usage is as follows: wx.hideToast(Object object)

  • Functional description: Hide message prompt box.
  • Parameters and descriptions: Object object
PropertiesTypeDefault valueRequiredDescription
noConflictbooleanfalseNoCurrently toast and loading related interfaces can be mixed with each other. This parameter can be used to cancel the mixed features
successFunction-NoCallback function for successful interface call
failFunction-NoCallback function for failed interface call
completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)

showActionSheet

TIP

The API usage is as follows: wx.showActionSheet(Object object)

TIP

  • For Android versions below 6.7.2, when you click cancel or mask, the callback fail, errMsg is 'fail cancel'.
  • For Android versions 6.7.2 and above and iOS, clicking the mask will not close the modal pop-up window, so try to avoid using the "Cancel" branch to implement business logic.
  • Functional description: Show the operation menu
  • Parameters and descriptions: Object object
PropertiesTypeDefault valueRequiredDescription
itemListarray.<string>-YesButton text array, the maximum array length is 8
itemColorstring#000000NoButton text color
successFunction-NoCallback function for successful interface call
failFunction-NoCallback function for failed interface call
completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)
  • object.success callback function parameters: Object res
PropertiesTypeDescription
tapIndexnumberThe button number clicked by the user, from top to bottom, starting from 2
  • Sample code:
js
wx.showActionSheet({
  itemList: ['A', 'B', 'C'],
  success (res) {
    console.log(res.tapIndex)
  },
  fail (res) {
    console.log(res.errMsg)
  }
})

showLoading

TIP

The API usage is as follows: wx.showLoading(Object object)

  • Functional description: Show the loading prompt box, wx.hideLoading Can close the prompt box.
  • Parameters and descriptions: Object object
PropertiesTypeDefault valueRequiredDescription
titlestring-YesPrompt content
maskbooleanfalseNoWhether to display a transparent mask to prevent touch penetration
successFunction-NoCallback function for successful interface call
failFunction-NoCallback function for failed interface call
completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)
  • Sample code:
js
wx.showLoading({
  title: 'loading',
})

setTimeout(function () {
  wx.hideLoading()
}, 2000)

TIP

showModal

TIP

The API usage is as follows: wx.showModal(Object object)

TIP

  • For Android versions below 6.7.2, when you click cancel or mask, the callback fail, errMsg is 'fail cancel'.
  • For Android versions 6.7.2 and above and iOS, clicking the mask will not close the modal pop-up window, so try to avoid using the "Cancel" branch to implement business logic.
  • Functional description: Show the modal dialog box
  • Parameters and descriptions: Object object
PropertiesTypeDefault valueRequiredDescription
titlestring-NoTitle of prompt
contentstring-NoPrompt content
showCancelbooleantrueNoWhether to display the cancel button
cancelTextstringcancelNoText of the cancel button, up to 4 characters
cancelColorstring#000000NoText color of the cancel button, must be a color string in hexadecimal format
confirmTextstringconfirmNoConfirm the text of the button, up to 4 characters
confirmColorstring#576B95NoThe text color of the confirmation button must be a hexadecimal formatted color string
successFunction-NoCallback function for successful interface call
failFunction-NoCallback function for failed interface call
completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)
  • object.success callback function parameters: Object res
PropertiesTypeDescription
confirmbooleanWhen true, it means the user clicked the OK button
cancelbooleanWhen true, it means the user clicked Cancel (used by the Android system to distinguish whether to close by clicking the mask or the cancel button)
  • Sample code:
js
wx.showModal({
  title: 'Prompt',
  content: 'This is a modal dialog box',
  success (res) {
    if (res.confirm) {
      console.log(User clicked "Confirm")
    } else if (res.cancel) {
      console.log(User clicked "Cancel")
    }
  }
})

showToast

TIP

The API usage is as follows: wx.showModal(Object object)

  • Functional description: Show the message prompt box
  • Parameters and descriptions: Object object
PropertiesTypeDefault valueRequiredDescription
titlestring-YesPrompt content
iconstringsuccessNoIcon, its legal value is:
1.success: Show success icon, at this time the title text is displayed up to 7 Chinese characters
2.error: Show failure icon, at this time the title text is displayed up to 7 Chinese characters
3.loading: Show loading icon, at this time the title text is displayed up to 7 Chinese characters
4.none: Do not display icon, at this time the title text can display up to two lines
imagestring-NoLocal path of custom icon, image has higher priority than icon
durationnumber1500NoDelay time of prompt
maskbooleanfalseNoWhether to display a transparent mask to prevent touch penetration
successFunction-NoCallback function for successful interface call
failFunction-NoCallback function for failed interface call
completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)
  • Sample code:
js
wx.showToast({
  title: 'success',
  icon: 'success',
  duration: 2000
})

TIP

enableAlertBeforeUnload

TIP

The API usage is as follows: wx.enableAlertBeforeUnload(Object object)

  • Functional description: Open the applet page and return to the inquiry dialog box

  • Pop-up condition:

    • When the user is on a non-home page/bottom page in the mini program.
    • Return on the official navigation bar.
    • Self-drawn return key in full screen mode.
    • android system back key.

      TIP

      • No interception when sliding back with gesture.
      • In any scenario, this function should not block the user from exiting the mini program.
  • Parameters and descriptions: Object object

PropertiesTypeDefault valueRequiredDescription
messagestring-YesAsk dialog content
successFunction-NoCallback function for successful interface call
failFunction-NoCallback function for failed interface call
completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)

disableAlertBeforeUnload

TIP

The API usage is as follows: wx.disableAlertBeforeUnload(Object object)

  • Functional description: Close the applet page and return to the inquiry dialog box
  • Parameters and descriptions: Object object
PropertiesTypeDefault valueRequiredDescription
successFunction-NoCallback function for successful interface call
failFunction-NoCallback function for failed interface call
completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)