VTabs

Tabs allow the user to switch between different views.

Vtabs

Attribute NameDescriptionTypeDefaultMandatory
activeTabIndex of the currently active tabNumbertrue
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.Arraytrue
swipeableSwipeable or notBooleantrue
tabBarActiveBgColortabBar background color in active   statusStringfalse
tabBarInactiveBgColortabBar background color in inactive   statusStringfalse
tabBarActiveTextColorActive Tab text color of the tabBarStringfalse
tabBarInactiveTextColorInactive Tab text color of the   tabBarStringfalse
tabBarlineColortabBar sideline colorStringfalse
onTabClickCallback when the tab is clicked(index: Number) => voidfalse
onChangeTrigger on vtab-content change(index: Number) => voidfalse

Vtab-content

View content

Attribute NameDescriptionTypeDefaultMandatory
anchorUnique anchor value of listStringtrue

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,
    });
  },
});