百度智能小程序 移除右上角的文本

2020-09-05 14:10 更新

swan.removeTabBarBadge

解释:移除 tabBar 某一项右上角的文本。

方法参数

Object object

object参数说明

属性名类型必填默认值说明

index

Number

tabBar 的哪一项,从左边算起

success

Function

接口调用成功的回调函数

fail

Function

接口调用失败的回调函数

complete

Function

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

示例 

在开发者工具中打开


图片示例



代码示例

<view class="wrap">
    <button type="primary" bindtap="setTabBarBadge">
    {{ !hasSetTabBarBadge ? '设置tab徽标' : '移除tab徽标' }}
    </button>
</view>
Page({
    setTabBarBadge() {
        if (this.data.hasSetTabBarBadge) {
            this.removeTabBarBadge()
            return
        }
        this.setData({
            hasSetTabBarBadge: true
        })
        swan.setTabBarBadge({
            index: 1,
            text: '1',
        })
    },

    removeTabBarBadge() {
        this.setData({
            hasSetTabBarBadge: false
        })
        swan.removeTabBarBadge({
            index: 1,
        })
    }
});

错误码

Android

错误码说明

1001

执行失败

iOS

错误码说明

202

解析失败,请检查参数是否正确

1001

当前页面不含 tabbar


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号