Tab Bar
WdTabBar
Applicable Scenarios
Used to implement Tab bar navigation effects on pages.
Basic Capabilities Description
- In the tab list properties, selecting a single tab allows configuration of attributes such as tab title, icon style, and redirect page. Supports setting independent menus for PC and mobile ends.
The selected effect is determined by the page properties in the tab and automatically matched.
Extended Scenarios Description
The Tab bar component is fixed to the bottom of the page and reused across multiple pages.
- Click "Layout Design" in the upper-left corner of the editor to access the application layout.
- Click "New Layout" to select "Tab Bar Navigation Layout" and create a Tab bar application layout.
- Return to "Page Design", select the page node in the outline tree, and set the "Page Layout" to "Tab Bar Navigation Layout" in the page properties area to complete the fixation to the bottom of the page.
- You can select other pages and set the "Page Layout" to "Tab Bar Navigation Layout" in the page properties area to reuse it.
Example
Interactive Preview
Property Introduction
External properties received by the component
Property Name | Property Identifier | Type | Description |
---|
标签列表 | tabs | object | 标签列表 Example: { "isMultiTerminal": false, "menuData": [ { "title": "标签1", "key": "1", "iconUrl": "td:home" }, { "title": "标签2", "iconUrl": "td:app", "key": "2" }, { "title": "标签3", "iconUrl": "td:user", "key": "3" } ], "mobileMenuData": [] } |
路由方式 | routeType | string | 路由跳转方式,当启用路由时生效 Example: "redirectTo" |
Events
Events exposed by the component. You can listen to component events to trigger external actions
Event Name | Event Code | Event Output Parameters event.detail | Applicable Scenarios | Description |
---|
点击 | tap | object
| Compatible with all platforms | - |
选项卡切换 | change | object
| Compatible with all platforms | - |
Property API
Through the Property API, you can access the internal state and property values of components. You can access internal values using$w.componentId.propertyName
, such as $w.input1.value
. For details, please refer to Property API
Read-only Property Name | Property Identifier | Type | Description |
---|
标签列表 | tabs | array | |
选中标签 | selectedTab | object | 当前选中标签 |
Method API
Through the Method API, you can programmatically trigger internal methods of components, such as submitting forms, displaying popups, etc. You can call component methods using $w.componentId.methodName
, such as $w.form1.submit()
Method Name | Method Identifier | Parameters | Method Description |
---|
设置选中标签 | setSelectTab | object
| 设置选中标签 |
Style API
Through the Style API, you can override the styles of internal elements in components to achieve customization. For example, in the low-code editor, you can write styles for all button components using #wd-page-root .wd-btn
, and control individual component styles with :scope
. For detailed instructions, please refer toStyle API
Name | Class Name | Description and Examples |
---|
根元素 | .wd-tabbar | 组件根元素
|
PC 端根元素 | .wd-pc-tabbar | 可以为 PC 端的编写样式
|
H5 端根元素 | .wd-h5-tabbar | 可以为 H5 端的编写样式
|
小程序 端根元素 | .wd-mp-tabbar | 可以为 小程序 端的编写样式
|
文本标签容器 | .wd-tabbar__item | 可以为选项区设置样式
|
选中态的标签容器 | .wd-tabbar__item.is-selected | 可以为选中选项区域设置样式
|
选项文本标签 | .wd-tabbar__item-text | 可以为选项文本标签设置样式
|
选项图标(图片) | .wd-tabbar__item .wd-image | 可以为选项文本标签设置样式
|
选项图标(图标) | .wd-tabbar__item .wd-icon | 可以为选项文本标签设置样式
|
Frequently Asked Questions
How to set the text color in the selected state of the Tab bar?
In the Tab bar, the Style API can be used in conjunction to customize the text color in the selected state. The default color is blue, which can also be changed by applying themes.