抖音开放平台Logo
开发者文档
“/”唤起搜索
控制台
  • JavaScript API
  • API 概览
  • 基础
  • 界面
  • 渲染
  • 数据缓存
  • 文件
  • 位置
  • 设备
  • 网络
  • 媒体
  • Worker
  • 数据分析
  • 支付
  • 广告
  • 开放能力
  • 登录
  • 侧边栏能力
  • 设置
  • 授权
  • 添加到桌面
  • 游戏排行榜
  • 订阅消息
  • 开放数据域
  • 开放数据
  • 开放数据分组
  • 客服消息
  • 直播能力
  • 推荐流直出游戏能力
  • 社交互动能力
  • 公会群能力
  • 意见反馈
  • 游戏站
  • 转发
  • 关注
  • 游戏内关注抖音号
  • 关注头条号
  • tt.createFollowButton
  • FollowButton
  • FollowButton
  • FollowButton.onTap
  • FollowButton.offTap
  • FollowButton.destroy
  • FollowButton.show
  • FollowButton.hide
  • tt.checkFollowState
  • 群聊
  • 收藏
  • C# API
  • 基础库 1.19.0 开始支持本方法,这是一个同步方法。

    监听按钮点击事件。当按钮时,唤起关注弹层,弹层被关闭时触发用户回调。

    前提条件无
    业务背景无
    使用限制无
    注意事项无
    相关教程无

    语法

    FollowButton.onTap(callback)

    参数说明

    callback

    类型默认值必填说明最低支持版本
    function是
    回调函数
    1.19.0

    callback 是一个回调函数,接收 object 类型的参数,属性如下:

    属性名类型说明最低支持版本
    buttonIdstring
    关注按钮的 id 标识,每一个按钮对应唯一一个 id
    1.19.0
    errCodestring
    关注结果错误码,详见下方取值
    1.19.0
    errMsgstring
    关注完成时的详细信息。成功时为"ok" 失败时为详细错误信息
    1.19.0

    返回值

    无

    代码示例

    const followButton = tt.createFollowButton({ type: "image", image: "images/follow-button.png", style: { left: 20, top: 40, width: 150, height: 40, lineHeight: 40, backgroundColor: "#ff0000", textColor: "#ffffff", textAlign: "center", fontSize: 16, borderRadius: 4, borderWidth: 1, borderColor: "#ff0000", }, }); followButton.onTap((res) => { const { buttonId, errCode, errMsg } = res; tt.showModal({ title: "关注", content: `关注按钮id:${buttonId}, errCode: ${errCode}, 详细信息:${errMsg}`, }); });

    errCode 取值

    值
    说明
    0
    关注成功
    1
    关闭弹窗,取消关注
    2
    关注失败,接口错误
    3
    关注失败,网络错误