@uni/toast
v1.1.1
Published
[![npm](https://img.shields.io/npm/v/@uni/toast.svg)](https://www.npmjs.com/package/@uni/toast)
Downloads
29
Readme
toast
Universal toast, you can choose how many seconds after disappearing
Support
Install
$ npm install @uni/toast --save
Usage
import { showToast, hideToast } from '@uni/toast';
showToast('Hi');
hideToast();
Methods
showToast(options: object | string)
Arguments
| Property | Type | Description | Default |
| -------- | -------- | ------------------------------------------- | :-----: |
| content | string
| content of the message | - |
| type | string
| Type of popup | none |
| duration | number
| Time in millisecond before Toast is closed. | 2000 |
| success | function
| The callback function for a successful API call | - |
| fail | function
| The callback function for a failed API call | - |
| complete | function
| The callback function used when the API call completed (always executed whether the call succeeds or fails) | - |
Valid type
| Value | Description | Support | No Support | |---------|-------------|----------------|------------------| | success | Show success icon | | | | fail | Show fail icon | | | | loading | Show loading icon | | | | none | No icon | | |
Special Arguments
| Property | Type | Description | Default | Support |
| -------- | -------- | ------------------- | :----: | -----|
| image | string
| The local path of the custom icon, the priority of image is higher than icon | - | |
| mask | boolean
| Whether to display a transparent mask to prevent touch penetration | none | |
hideToast()
Hides the loading prompt box