Taro.showToast(option)
Displays the message prompt box.
Note
- Either
Taro.showLoading
orTaro.showToast
can be displayed. Taro.showToast
should be paired withTaro.hideToast
.
Type
(option: Option) => Promise<CallbackResult>
Parameters
Option
Property | Type | Required | Description |
---|---|---|---|
title | string | Yes | Prompt content |
complete | (res: CallbackResult) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
duration | number | No | The delay time for a prompt |
fail | (res: CallbackResult) => void | No | The callback function for a failed API call |
icon | "success" | "loading" | "none" | No | Icon |
image | string | No | The local path of the custom icon. image has priority over icon. |
mask | boolean | No | Indicates whether to display a transparent mask to prevent touch penetration |
success | (res: CallbackResult) => void | No | The callback function for a successful API call |
Sample Code
Taro.showToast({
title: 'Success',
icon: 'success',
duration: 2000
})
API Support
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Taro.showToast | ✔️ | ✔️ | ✔️ |