my.prompt
Pop up a dialog to show the prompt message.
Supported types of mini programs: DSL, H5+
Supported SDK versions:
- Android: 2.66.0
- iOS: 2.77.0
Sample code
my.prompt({
title: 'Title',
message: 'Explain the current status and prompt the user solution. It is best not to exceed two lines.',
placeholder: 'Leave a message to a friend',
okButtonText: 'Confirm',
cancelButtonText: 'Cancel',
success: (result) => {
my.alert({
title: JSON.stringify(result),
});
},
});Parameters
Property | Type | Required | Description |
title | String | No | Title of prompt box. |
message | String | Yes | Text of prompt box, which is “Enter contents here” by default. |
placeholder | String | No | Prompt text for the entry box. |
align | String | No | Message alignment. Valid values are:
The default value is |
okButtonText | String | No | OK button text, which is OK by default. |
cancelButtonText | String | No | Cancel button text, which is Cancel by default. |
success | Function | No | Callback function upon call success. |
fail | Function | No | Callback function upon call failure. |
complete | Function | No | Callback function upon call completion (to be executed upon either call success or failure). |
Success Callback Function
The incoming parameter is of the Object type with the following attributes:
Property | Type | Description |
ok | Boolean | Click OK to return true; click Cancel to return false. |
confirmColor | String | Indicates the Confirm button text color. Supports hexadecimal format such as "#108EE9". Default value: "#1677FF". |
inputValue | String | When OK is true, return the user's entry. |
Error Codes
Error Code | Error Message | Further Action |
3 | unknown error! | No further action required. Context is unavailable. |