HomeDocs
Skip to main content

Show Toast

methodName: showToast

Additional Parameters:

PropertyTypeRequiredDefaultDescription
titleStringYesThe content of the toast.
iconStringNoThe 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.
durationNumberNo1500The duration of the toast in milliseconds.
maskBooleanNofalseWhether to show a transparent mask to prevent touch events from passing through.

Success Callback Function

Parameters

Object res

PropertyTypeDescription
successStringDescribes whether the interface call was successful or not. "true" for success, "false" for failure.

Fail Callback Function

Parameters

Object res

PropertyTypeDescription
successStringDescribes whether the interface call was successful or not. "true" for success, "false" for failure.
errMsgStringError 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);
},
});
}
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.