showToast(params: Object)

版本要求:
BaseKit≥2.0.1@ray-js/ray≥0.3.23
支持平台:
iOSAndroid
import { showToast } from '@ray-js/ray';

// Promise 调用
try {
  const res = await showToast({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

描述

显示消息提示框

参数

属性类型必填默认值说明
titlestring是-提示的内容
iconstring否"success"图标 'success' / 'error' / 'loading' / 'none'
imagestring否-自定义图标的本地路径,image 的优先级高于 icon
durationnumber否1500提示的延迟时间(仅iOS生效)
maskboolean否false是否显示透明蒙层,防止触摸穿透
complete() => void否-接口调用结束的回调函数(调用成功、失败都会执行)
success() => void否-接口调用成功的回调函数
fail(params: Object) => void否-接口调用失败的回调函数
fail 回调参数
属性类型说明
errorMsgstring错误信息
errorCodestring | number错误码
错误扩展

返回值

无

示例代码

import { showToast } from '@ray-js/ray'

// 显示消息提示框
showToast({
  title: "操作成功",
  icon: "success",
  duration: 1500,
  mask: false,
  success: () => console.log("toast 已显示"),
  fail: error => console.error(error),
});