Show Toast
methodName: showToast
Additional Parameters:
Property | Type | Required | Default | Description |
---|---|---|---|---|
title | String | Yes | The content of the toast. | |
icon | String | No | The icon to show in the toast: - "success": Shows a success icon. When the text is too long, the title text can display a maximum of 7 Chinese characters. - "error": Shows an error icon. When the text is too long, the title text can display a maximum of 7 Chinese characters. - "loading": Shows a loading icon. When the text is too long, the title text can display a maximum of 7 Chinese characters. - "none": Doesn't show an icon, allowing the title text to display up to two lines. | |
duration | Number | No | 1500 | The duration of the toast in milliseconds. |
mask | Boolean | No | false | Whether to show a transparent mask to prevent touch events from passing through. |
Success Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
success | String | Describes whether the interface call was successful or not. "true" for success, "false" for failure. |
Fail Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
success | String | Describes whether the interface call was successful or not. "true" for success, "false" for failure. |
errMsg | String | Error message. |
Example Usage
const dlt = window['@transsion/byteh5bridge'];
const canCallDlt = dlt && window.dltms && window.dltms.isMiniShellGame();
if (canCallDlt) {
dlt.callApi('showToast', {
title: 'Toast Title',
icon: 'success',
duration: 1000,
mask: true,
success: (res) => {
console.log('Success: ', res);
},
fail: (res) => {
console.log('Fail: ', res);
},
complete: (res) => {
console.log('Complete: ', res);
},
});
}