my.settabbaritem(object object)
基础库 或更高版本; 且 支付宝客户端 10.1.32 或更高版本; 若版本较低,建议采取 兼容处理 。
支小宝客户端 支持
安诊儿客户端 支持
主体: 企业支付宝小程序 、 个人支付宝小程序
相关文档: my.settabbarbadge 、 tabbar 常见问题
设置 tabbar 某一项的文字、图标。
object object
查看示例
属性 | 类型 | 默认值 | 必填 | 描述 |
---|---|---|---|---|
index | number | - | 是 | tabbar 的项数序号,最左边的为 0,往右顺次增大 |
text | string | - | 否 | tab 按钮上的文字 |
iconpath | string | - | 否 | 图片路径。建议尺寸为 81px * 81px,支持 png/jpeg/jpg/gif 图片格式,支持网络图片。 |
selectediconpath | string | - | 否 | 选中时的图片路径。建议尺寸为 81px * 81px,支持 png/jpeg/jpg/gif 图片格式,支持网络图片。 |
success | function | - | 否 | 调用成功的回调函数 |
fail | function | - | 否 | 调用失败的回调函数 |
complete | function | - | 否 | 调用结束的回调函数(调用成功、失败都会执行) |
fail 回调的参数为 object,error
属性为错误码,errormessage
属性为错误消息。
错误码 | 错误消息 | 凯发app官方网站的解决方案 |
---|---|---|
1 | currently using customize tabbar. the api [settabbaritem] does not support! |
自定义的 tabbar 不支持使用 my.settabbaritem 设置内容。 |
2 | 接口参数无效 |
参考入参说明,检查参数类型及参数填写规范。 |
11 | 当前页面不在 tabbar 上。 |
需要在 tabbar 页面上调用此接口。 |
my.settabbaritem({
index: 0,
text: 'text',
iconpath: '/image/icon-hom.png',
selectediconpath: '/image/icon-home-selected.png',
success: function(res) {
console.log(res); // { "success": true}
},
fail: function(err) {
console.log(err);
}
});
-
tipmy.settabbarbadge 和 my.settabbaritem 同时使用时,有概率会遇到 badge 被遮盖的情况。可通过在 my.settabbaritem 的 success 回调里调用 my.settabbarbadge 解决。