VTabs

Tabs allow the user to switch between different views.

Vtabs

Property

DescriptionType

Required

activeTabIndex of the currently active tab.Number

Yes

tabstab data, including the tab title, unique list anchor value, as well as the   badge type badgeType, which includes dot and text, and is not displayed if the badgeType is not set. Badge text badgeText takes effect when the badgeType is text.Array

Yes

swipeableAn indicator of whether the tab can be swiped or not.Boolean

Yes

tabBarActiveBgColortabBar background color in active status.String

No

tabBarInactiveBgColortabBar background color in inactive status.String

No

tabBarActiveTextColorActive Tab text color of the tabBar.String

No

tabBarInactiveTextColorInactive Tab text color of the tabBar.String

No

tabBarlineColortabBar sideline color.String

No

onTabClickCallback when the tab is clicked.(index: Number) => void

No

onChangeTrigger on vtab-content change.(index: Number) => void

No

Vtab-content

View content

Property

DescriptionType

Required

anchorUnique anchor value of list.String

Yes

Example

copy
{
  "defaultTitle": "AntUI Component Library",
  "usingComponents": {
    "vtabs": "mini-antui/es/vtabs/index",
    "vtab-content": "mini-antui/es/vtabs/vtab-content/index"
  }
}
copy
<view>
  <vtabs
    tabs="{{tabs}}"
    onTabClick="handleChange"
    onChange="onChange"
    activeTab="{{activeTab}}"
  >
    <block a:for="{{tabs}}">
      <vtab-content anchor="{{item.anchor}}">
        <view style="border: 1px solid #eee; height: 800px; box-sizing: border-box">
          <text>content of {{item.title}}</text>
        </view>
      </vtab-content>
    </block>
  </vtabs>
</view>
copy
Page({
  data: {
    activeTab: 2,
    tabs: [
      { title: 'Option two', anchor: 'a', badgeType: 'dot' },
      { title: 'Option', anchor: 'b', badgeType: 'text', badgeText: 'New' },
      { title: 'Option three', anchor: 'c' },
      { title: 'Option four', anchor: 'd' },
      { title: 'Option five', anchor: 'e' },
      { title: 'Option six', anchor: 'f' },
    ],
  },
  handleChange(index) {
    this.setData({
      activeTab: index,
    });
  },
  onChange(index) {
    console.log('onChange', index);
    this.setData({
      activeTab: index,
    });
  },
});