抖音开放平台Logo
控制台

tt.showLoading
收藏
我的收藏

基础库 1.0.0 开始支持本方法,这是一个异步方法。

显示灰色背景的 loading 提示框。该提示框不会主动隐藏。

前提条件
业务背景
使用限制
注意事项
  • 尚未支持mask参数。
  • loading 的实现基于 toast,等同于icon为loading,duration为24小时的 toast。
  • 多次弹出 toast/loading 时,后一个会立刻覆盖前一个。
相关教程

语法

tt.showLoading(options)

参数说明

options 为 object 类型,属性如下:

属性名类型默认值必填说明最低支持版本
titlestring

内容,最多显示 7 个汉字长度的文本

1.0.0
successfunction
接口调用成功的回调函数
1.0.0
failfunction
接口调用失败的回调函数
1.0.0
completefunction
接口调用结束的回调函数(调用成功、失败都会执行)
1.0.0

回调成功

object 类型,属性如下:

属性名类型说明最低支持版本
errMsgstring

"showLoading:ok"

1.0.0

回调失败

object 类型,属性如下:

属性名类型说明最低支持版本
errMsgstring

"showLoading:fail " + 详细错误信息

1.0.0

扫码体验

请使用字节宿主APP扫码

代码示例

开发者工具中预览

tt.showLoading({
  title: "请求中,请稍后...",
  success(res) {
    console.log(`${res}`);
  },
  fail(res) {
    console.log(`showLoading调用失败`);
  },
});