使用用例

使用Tabs 和 TabPane 组件来构建切换选项卡

所有 TabPane 的子元素会被GScrollView组件包裹
<template>
  <GTabs>
    <GTabPane tabKey="tab1" title="tab1"> this is tab A</GTabPane>
    <GTabPane tabKey="tab2" title="tab2"> this is tab B</GTabPane>
    <GTabPane tabKey="tab3" title="tab3"> this is tab C</GTabPane>
    <GTabPane tabKey="tab4" title="tab4"> this is tab D</GTabPane>
  </GTabs>
</template>

默认值

this is tab C
<template>
  <GTabs default="tab3">
    <GTabPane tabKey="tab1" title="tab1"> this is tab A</GTabPane>
    <GTabPane tabKey="tab2" title="tab2"> this is tab B</GTabPane>
    <GTabPane tabKey="tab3" title="tab3"> this is tab C</GTabPane>
    <GTabPane tabKey="tab4" title="tab4"> this is tab D</GTabPane>
  </GTabs>
</template>

选择禁用

<template>
  <GTabs :disable="['tab3','tab1']">
    <GTabPane tabKey="tab1" title="tab1"> this is tab A</GTabPane>
    <GTabPane tabKey="tab2" title="tab2"> this is tab B</GTabPane>
    <GTabPane tabKey="tab3" title="tab3"> this is tab C</GTabPane>
    <GTabPane tabKey="tab4" title="tab4"> this is tab D</GTabPane>
  </GTabs>
</template>

受控组件

<template>
  <GSelect 
    style="margin: 10px 0;" 
    v-model="tab"
    :options="[
      { text: 'tab1', value: 'tab1' },
      { text: 'tab2', value: 'tab2' },
      { text: 'tab3', value: 'tab3' },
      { text: 'tab4', value: 'tab4' },
    ]"
  />
  <GTabs :disable="['tab3','tab1']" :active="tab">
    <GTabPane tabKey="tab1" title="tab1"> this is tab A</GTabPane>
    <GTabPane tabKey="tab2" title="tab2"> this is tab B</GTabPane>
    <GTabPane tabKey="tab3" title="tab3"> this is tab C</GTabPane>
    <GTabPane tabKey="tab4" title="tab4"> this is tab D</GTabPane>
  </GTabs>
</template>
<script setup>
  import { ref } from 'vue'
  const tab = ref('tab1')
</script>

参数定义

Tab

参数说明类型是否可选默认值
default默认选中项string可选-
disable禁用项string[]可选-
active控制权移交外部string可选-

TabPane

参数说明类型是否可选默认值
tabKey选项卡的标识string必须-
title选项卡的标题string可选-

事件说明

事件名说明回调参数
click点击选项卡时触发(tab: string) => void
change切换选项卡时触发(tab: string) => void
Last Updated:
Contributors: shi-zhong