toast
通用弱提示,可选择多少秒之后消失
支持
安装
$ npm install @uni/toast --save
示例
import { showToast, hideToast } from '@uni/toast';
showToast('Hi');
hideToast();
你也可以从大包引入:
import { toast } from '@uni/apis';
方法
showToast(options?: object)
参数
成员 | 类型 | 描述 | 默认值 |
---|---|---|---|
content | string |
文字内容 | - |
type | string |
弹窗类型 | none |
duration | number |
显示时长,单位为 ms | 2000 |
success | function |
成功回调 | - |
fail | function |
失败回调 | - |
complete | function |
结束回调 | - |
type的合法值
值 | 说明 | 支持 | 不支持 |
---|---|---|---|
success | 显示成功图标 | ||
fail | 显示失败图标 | ||
loading | 显示加载图标 | ||
none | 不显示图标 |
差异化参数
成员 | 类型 | 描述 | 默认值 | 支持 |
---|---|---|---|---|
image | string |
自定义图标的本地路径,image 的优先级高于 icon | - | |
mask | boolean |
是否显示透明蒙层,防止触摸穿透 | none |
hideToast()
隐藏Toast