支付寶小程序擴展組件 縱向選項卡·Vtabs

2020-09-18 11:19 更新

用于讓用戶在不同的視圖中進行切換。

掃碼體驗

示例代碼

{
  "defaultTitle": "Vtabs",
  "usingComponents": {
    "vtabs": "mini-ali-ui/es/vtabs/index",
    "vtab-content": "mini-ali-ui/es/vtabs/vtab-content/index"
  }
}
 <vtabs
  tabs="{{tabs}}"
  onTabClick="handleChange"
  onChange="onChange"
  activeTab="{{activeTab}}"
  sameFontSize="{{false}}"
  tabBarlineShow="{{false}}"
>
  <block a:for="{{tabs}}">
    <vtab-content anchor="{{item.anchor}}">
      <view style="height: {{item.anchor === 'b'?'50vh':'100vh'}};background-color: {{item.anchor === 'b'?'#ccc':''}};">
        <text>content of {{item.title}}</text>
      </view>
    </vtab-content>
  </block>
</vtabs>
Page({
  data: {
    activeTab: 2,
    tabs: [
      { title: '選項二', anchor: 'a', number: '6' },
      { title: '選項', anchor: 'b', number: '66' },
      { title: '不超過五字', anchor: 'c', number: '99+' },
      { title: '選項四選項四選項四選項四', anchor: 'd' },
      { title: '選項五', anchor: 'e' },
      { title: '選項六', anchor: 'f' },
    ],
  },
  handleChange(index) {
    this.setData({
      activeTab: index,
    });
  },
  onChange(index) {
    this.setData({
      activeTab: index,
    });
  },
});

屬性

vtabs 縱向選項卡包含了 <vtabs><vtab-content> 兩部分。

vtabs

屬性 類型 默認值 描述值 必填 最低版本
className String - 自定義 class - -
activeTab Number 0 當前激活 Tab 索引。 - -
tabs Array<title, anchor> - tab 數(shù)據(jù)。 true -
animated Boolean false 是否開啟動畫。 - -
swipeable Boolean true 是否可滑動切換。 - -
tabBarActiveTextColor String #1677FF tabBar 激活狀態(tài)文字顏色。 - -
tabBarActiveBgColor String #ffffff tabBar 激活狀態(tài)背景色。 - -
tabBarInactiveTextColor String #333333 tabBar 非激活狀態(tài)文字顏色。 - -
tabBarInactiveBgColor String #f5f5f5 tabBar 非激活狀態(tài)背景色。 - -
tabBarlineColor String #1677FF tabBar 激活狀態(tài)邊線。 - -
onTabClick EventHandle (index: Number) => void tab 被點擊的回調(diào)。 - -
onChange EventHandle (index: Number) => void vtab-content 變化時觸發(fā)。 - -
sameFontSize Boolean true tab 選項卡的文字是否保持相同,如為 false,激活態(tài)的文字會大一點。 - 1.0.6
tabBarlineShow Boolean true tab 選項卡激活態(tài)側(cè)邊豎線是否顯示。 - 1.0.6
onTabFirstShow EventHandle (index: Number, anchor: String) => {} tab 選項卡首次出現(xiàn)時的回調(diào). - 1.0.12

vtab-content

屬性 類型 默認值 描述 必填
anchor String - 列表唯一錨點值。 true

Bug & Tip

  • tabs 數(shù)組中需要包含 vtab-content 中的 anchor;
  • tabs 數(shù)組的數(shù)據(jù)格式:[{ title: '', anchor: '', number: '99+',},]
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號