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
组件接收的外部传入的属性
属性名 | 属性标识 | 类型 | 说明 |
---|
标签列表 | tabs | object | 标签列表 示例:{ "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 | 路由跳转方式,当启用路由时生效 示例:"redirectTo" |
Events
组件暴露的事件,可以监听组件的事件来触发一些外部的动作
事件名 | 事件code | 事件出参 event.detail | 适用情况 | 说明 |
---|
点击 | tap | object
| 兼容三端 | - |
选项卡切换 | change | object
| 兼容三端 | - |
Property API
通过属性 API,可以获取组件内部的状态和属性值,可以通过$w.componentId.propertyName
来访问组件内部的值,如 $w.input1.value
,详请请参考 属性 API
只读属性名 | 属性标识 | 类型 | 说明 |
---|
标签列表 | tabs | array | |
选中标签 | selectedTab | object | 当前选中标签 |
Method API
通过方法 API,可以通过程序触发组件内部的方法,比如提交表单,显示弹窗等, 可以通过$w.componentId.methodName
来调用组件方法,如 $w.form1.submit()
方法名 | 方法标识 | 参数 | 方法说明 |
---|
设置选中标签 | setSelectTab | object
| 设置选中标签 |
Style API
通过样式 API,可以覆盖组件中内部元素的样式来实现自定义,例如在低代码编辑器中中通过 #wd-page-root .wd-btn
即可为所有的按钮组件编写样式,通过 :scope
可以控制单个组件样式, 详细说明请参考样式 API
名称 | 类名 | 说明和示例 |
---|
根元素 | .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.