title: Taro.showToast(option)

sidebar_label: showToast

Displays the message prompt box.

Note

  • Either Taro.showLoading or Taro.showToast can be displayed.
  • Taro.showToast should be paired with Taro.hideToast.

Reference

Type

  1. (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

  1. Taro.showToast({
  2. title: 'Success',
  3. icon: 'success',
  4. duration: 2000
  5. })

API Support

API WeChat Mini-Program H5 React Native
Taro.showToast ✔️ ✔️ ✔️