Interaction
hideloading
TIP
The API usage is as follows: wx.hideLoading(Object object)
- Functional description: Hide loading prompt box.
- Parameters and descriptions: Object object
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| noConflict | boolean | false | No | Currently toast and loading related interfaces can be mixed with each other. This parameter can be used to cancel the mixed features |
| success | Function | - | No | Callback function for successful interface call |
| fail | Function | - | No | Callback function for failed interface call |
| complete | Function | - | No | Callback 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
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| noConflict | boolean | false | No | Currently toast and loading related interfaces can be mixed with each other. This parameter can be used to cancel the mixed features |
| success | Function | - | No | Callback function for successful interface call |
| fail | Function | - | No | Callback function for failed interface call |
| complete | Function | - | No | Callback 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
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| itemList | array.<string> | - | Yes | Button text array, the maximum array length is 6 |
| itemColor | string | #000000 | No | Button text color |
| success | Function | - | No | Callback function for successful interface call |
| fail | Function | - | No | Callback function for failed interface call |
| complete | Function | - | No | Callback function for interface call completion (executed regardless of success or failure) |
- object.success callback function parameters: Object res
| Properties | Type | Description |
|---|---|---|
| tapIndex | number | The button number clicked by the user, from top to bottom, starting from 0 |
- 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
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| title | string | - | Yes | Prompt content |
| mask | boolean | false | No | Whether to display a transparent mask to prevent touch penetration |
| success | Function | - | No | Callback function for successful interface call |
| fail | Function | - | No | Callback function for failed interface call |
| complete | Function | - | No | Callback function for interface call completion (executed regardless of success or failure) |
- Sample code:
js
wx.showLoading({
title: 'loading',
})
setTimeout(function () {
wx.hideLoading()
}, 2000)TIP
- wx.showLoading and wx.showToastOnly one can be displayed at a time.
- wx.showLoading Should be with wx.hideLoadingUsed in pairs.
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
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| title | string | - | No | Title of prompt |
| content | string | - | No | Prompt content |
| showCancel | boolean | true | No | Whether to display the cancel button |
| cancelText | string | cancel | No | Text of the cancel button, up to 4 characters |
| cancelColor | string | #000000 | No | Text color of the cancel button, must be a color string in hexadecimal format |
| confirmText | string | confirm | No | Confirm the text of the button, up to 4 characters |
| confirmColor | string | #576B95 | No | The text color of the confirmation button must be a hexadecimal formatted color string |
| success | Function | - | No | Callback function for successful interface call |
| fail | Function | - | No | Callback function for failed interface call |
| complete | Function | - | No | Callback function for interface call completion (executed regardless of success or failure) |
- object.success callback function parameters: Object res
| Properties | Type | Description |
|---|---|---|
| confirm | boolean | When true, it means the user clicked the OK button |
| cancel | boolean | When 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
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| title | string | - | Yes | Prompt content |
| icon | string | success | No | Icon, 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 |
| image | string | - | No | Local path of custom icon, image has higher priority than icon |
| duration | number | 1500 | No | Delay time of prompt |
| mask | boolean | false | No | Whether to display a transparent mask to prevent touch penetration |
| success | Function | - | No | Callback function for successful interface call |
| fail | Function | - | No | Callback function for failed interface call |
| complete | Function | - | No | Callback function for interface call completion (executed regardless of success or failure) |
- Sample code:
js
wx.showToast({
title: 'success',
icon: 'success',
duration: 2000
})TIP
- wx.showLoading and wx.showToastOnly one can be displayed at a time.
- wx.showLoading Should be with wx.hideLoadingUsed in pairs.
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
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| message | string | - | Yes | Ask dialog content |
| success | Function | - | No | Callback function for successful interface call |
| fail | Function | - | No | Callback function for failed interface call |
| complete | Function | - | No | Callback 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
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| success | Function | - | No | Callback function for successful interface call |
| fail | Function | - | No | Callback function for failed interface call |
| complete | Function | - | No | Callback function for interface call completion (executed regardless of success or failure) |