FollowButton.onTap
监听按钮点击事件。当按钮时,唤起关注弹层,弹层被关闭时触发用户回调。
语法
FollowButton.onTap(callback)
参数说明
Function callback
回调参数
object 类型,属性如下:
属性 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
buttonId | string | 关注按钮的 id 标识,每一个按钮对应唯一一个 id | 1.19.0 |
errCode | number | 关注结果错误码,详见 errCode 取值 | 1.19.0 |
errMsg | string | 关注完成时的详细信息。成功时为"ok" 失败时为详细错误信息 | 1.19.0 |
errCode 取值
值 | 说明 |
---|---|
0 | 关注成功 |
1 | 关闭弹窗,取消关注 |
2 | 关注失败,接口错误 |
3 | 关注失败,网络错误 |
代码示例
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}`,
});
});
Bug & Tip
暂无。
点击纠错
该文档是否对你的开发有所帮助?
有帮助
没帮助
该文档是否对你的开发有所帮助?
有帮助
没帮助