HomeDocs
Skip to main content

dlt.setTabBarBadge

Introduction​

Add text to the top right corner of a specific item in the tabBar.

Usage Limitations​

Supported in the basic library version 4.0.0 or higher.

Parameters​

Object object

PropertyTypeDefaultRequiredDescription
indexnumberYesThe index of the tabBar item, starting from the left, with an initial value of 0.
textstringYesThe text to display.
1. If the text contains more than 2 Chinese characters, it will be displayed as "..."​
2. If the string contains more than 4 characters, it will be displayed as "..."
successfunctionNoCallback function for a successful API call.
failfunctionNoCallback function for a failed API call.
completefunctionNoCallback function for the completion of the API call (executed whether the call is successful or not).

object.success Callback Function​

Parameters​

Object res​

PropertyTypeDescription
successstringtrue - Setting successful.

object.fail Callback Function​

Parameters​

Object res​

PropertyTypeDescription
successstringfalse - Setting failed.

Sample Code​

// pages/index/index.js
Page({
setTabBarBadge() {
dlt.setTabBarBadge({
index: 0,
text: '99+',
success: () => {
console.log('success');
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_private.mi@dlightek.com © 2024 MiniApp. All Rights Reserved.