tencent cloud

All product documents
Tencent Cloud Super App as a Service
Interaction
Last updated: 2025-02-24 17:10:35
Interaction
Last updated: 2025-02-24 17:10:35

hideLoading

This API is called using wx.hideLoading(Object object).
Feature description:Hides the loading prompt box.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
noConflict
boolean
false
False
Currently, toast and loading related APIs can be used interchangeably. This parameter can be used to cancel this feature.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).

hideToast

This API is called using wx.hideToast(Object object).
Feature description:Hides the message prompt box.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
noConflict
boolean
false
False
Currently, toast and loading related APIs can be used interchangeably. This parameter can be used to cancel this feature.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).

showActionSheet

This API is called using wx.showActionSheet(Object object).
Notes:
For Android versions earlier than 6.7.2, tapping cancel or the mask will trigger the fail callback with errMsg as "fail cancel".
For Android 6.7.2 and later, and iOS, tapping the mask will not close the modal popup. In the fail callback function, if errMsg is "fail cancel", it is not recommended to implement business logic in this scenario.
Feature description:Shows the action menu.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
itemList
array.<string>
-
True
Array of button text, with a maximum length of 6.
itemColor
string
#000000
False
Button text color.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).
object.success callback function parameter:Object res
Property
Type
Description
tapIndex
number
The index of the button tapped by the user, starting from 0.
Example:
wx.showActionSheet({
itemList: ['A', 'B', 'C'],
success (res) {
console.log(res.tapIndex)
},
fail (res) {
console.log(res.errMsg)
}
})

showLoading

This API is called using wx.showLoading(Object object).
Feature description:Shows the loading prompt box. You need to call wx.hideLoading to close the prompt box.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
title
string
-
True
The content of the prompt.
mask
boolean
false
False
Whether to show a transparent mask to prevent touch penetration.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).
Example:
wx.showLoading({
title: 'Loading',
})

setTimeout(function () {
wx.hideLoading()
}, 2000)
Notes:
wx.showLoading and wx.showToast cannot be shown at the same time.
wx.showLoading should be used with wx.hideLoading.

showModal

This API is called using is wx.showModal(Object object).
Notes:
For Android versions earlier than 6.7.2, tapping cancel or the mask will trigger the fail callback with errMsg as "fail cancel".
For Android 6.7.2 and later, and iOS, tapping the mask will not close the modal popup. In the fail callback function, if errMsg is "fail cancel", it is not recommended to implement business logic in this scenario.
Feature description:Shows the modal dialog box.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
title
string
-
False
The title of the prompt.
content
string
-
False
The content of the prompt.
showCancel
boolean
true
False
Whether to show the Cancel button.
cancelText
string
Cancel
False
The text of the Cancel button, which can contain up to four characters.
cancelColor
string
#000000
False
The color of the Cancel button text, must be a hexadecimal color string.
confirmText
string
OK
False
The text of the OK button, which can contain up to four characters.
confirmColor
string
#576B95
False
The color of the OK button text, must be a hexadecimal color string.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).
object.success callback function parameter:Object res
Property
Type
Description
confirm
boolean
true if the user tapped the OK button.
cancel
boolean
true if the user tapped the Cancel button (used to distinguish between tapping the mask to close or tapping the Cancel button on Android).
Example:
wx.showModal({
title: 'Prompt',
content: 'This is a modal pop-up',
success (res) {
if (res.confirm) {
console.log('The user taps OK')
} else if (res.cancel) {
console.log('The user taps Cancel')
}
}
})

showToast

This API is called using wx.showToast(Object object).
Feature description:Shows the message prompt box.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
title
string
-
True
The content of the prompt.
icon
string
success
False
Icon. Valid values:
success: Shows a success icon, with a maximum of seven characters for the title.
error: Shows a failure icon, with a maximum of seven characters for the title.
loading: Shows a loading icon, with a maximum of seven characters for the title.
none: No icon is displayed, and the title can display up to two lines.
image
string
-
False
The local path to a custom icon. The image has a higher priority than icon.
duration
number
1500
False
The duration of the prompt in milliseconds.
mask
boolean
false
False
Whether to show a transparent mask to prevent touch penetration.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).
Example:
wx.showToast({
title: 'Success',
icon: 'success',
duration: 2000
})
Notes:
wx.showLoading and wx.showToast cannot be shown at the same time.
wx.showLoading should be used with wx.hideLoading.

enableAlertBeforeUnload

This API is called using wx.enableAlertBeforeUnload(Object object).
Notes:
This API is supported in mini programs but not in mini games.
Feature description:Enables a confirmation dialog when the user tries to navigate away from a page in the mini program.
Conditions for showing the dialog box:
When the user is on a non-home page or the bottom-most page in the mini program.
When using the official navigation bar's back button.
When using a custom back button in full-screen mode.
When pressing the back button on an Android device.
Notes:
This feature does not intercept swipe gestures for navigation.
In any scenario, this feature should not prevent the user from exiting the mini program.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
message
string
-
True
The content of the confirmation dialog.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).

disableAlertBeforeUnload

This API is called using wx.disableAlertBeforeUnload(Object object).
Notes:
This API is supported in mini programs but not in mini games.
Feature description:Disables the confirmation dialog when the user tries to navigate away from a page in the mini program.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure).


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon