zhenyulei 5 years ago
parent
commit
216a98dd37
4 changed files with 387 additions and 280 deletions
  1. 27 0
      src/packages/tab/demo.vue
  2. 27 2
      src/packages/tab/doc.md
  3. 150 94
      src/packages/tab/tab.scss
  4. 183 184
      src/packages/tab/tab.vue

+ 27 - 0
src/packages/tab/demo.vue

@@ -6,7 +6,9 @@
         <nut-tab-panel tab-title="页签1">页签1</nut-tab-panel>
         <nut-tab-panel tab-title="页签2">页签2</nut-tab-panel>
         <nut-tab-panel tab-title="页签3">页签3</nut-tab-panel>
+        <nut-tab-panel tab-title="页签4">页签4</nut-tab-panel>
     </nut-tab>
+
     <h4>支持导航条在上下左右位置</h4>
     <nut-tab @tab-switch="tabSwitch">
       <nut-tab-panel
@@ -35,6 +37,7 @@
         v-html="value.content"
       ></nut-tab-panel>
     </nut-tab>
+    
     <nut-tab @tab-switch="tabSwitch" position-nav="bottom">
       <nut-tab-panel
         v-for="value in editableTabs"
@@ -45,6 +48,28 @@
       ></nut-tab-panel>
     </nut-tab>
 
+    <h4>支持滑动选择多个页签</h4>
+    <nut-tab @tab-switch="tabSwitch" :is-scroll="true">
+        <nut-tab-panel tab-title="页签1">页签1</nut-tab-panel>
+        <nut-tab-panel tab-title="页签2">页签2</nut-tab-panel>
+        <nut-tab-panel tab-title="页签3">页签3</nut-tab-panel>
+        <nut-tab-panel tab-title="页签4">页签4</nut-tab-panel>
+        <nut-tab-panel tab-title="页签5">页签5</nut-tab-panel>
+        <nut-tab-panel tab-title="页签6">页签6</nut-tab-panel>
+        <nut-tab-panel tab-title="页签7">页签7</nut-tab-panel>
+    </nut-tab>
+
+    <h4>支持滑动选择多个页签</h4>
+    <nut-tab @tab-switch="tabSwitch" :is-scroll="true" position-nav="left">
+        <nut-tab-panel tab-title="页签1">页签1</nut-tab-panel>
+        <nut-tab-panel tab-title="页签2">页签2</nut-tab-panel>
+        <nut-tab-panel tab-title="页签3">页签3</nut-tab-panel>
+        <nut-tab-panel tab-title="页签4">页签4</nut-tab-panel>
+        <nut-tab-panel tab-title="页签5">页签5</nut-tab-panel>
+        <nut-tab-panel tab-title="页签6">页签6</nut-tab-panel>
+        <nut-tab-panel tab-title="页签7">页签7</nut-tab-panel>
+    </nut-tab>
+
     <h4>禁止选中,默认选中某个标签</h4>
     <h4>如需要更新页面,请将监听变化的数据传入init-data</h4>
 
@@ -210,6 +235,8 @@ export default {
   .nut-tab-active {
     background: $primary-color;
     border: 0;
+    transition: all 0.3s ease-in-out;
+
   }
   .nav-bar {
     background: $primary-color;

+ 27 - 2
src/packages/tab/doc.md

@@ -75,6 +75,31 @@ export default {
   }
 };
 ```
+## 支持滑动选择多个页签
+
+```html
+  <nut-tab @tab-switch="tabSwitch" :is-scroll="true">
+      <nut-tab-panel tab-title="页签1">页签1</nut-tab-panel>
+      <nut-tab-panel tab-title="页签2">页签2</nut-tab-panel>
+      <nut-tab-panel tab-title="页签3">页签3</nut-tab-panel>
+      <nut-tab-panel tab-title="页签4">页签4</nut-tab-panel>
+      <nut-tab-panel tab-title="页签5">页签5</nut-tab-panel>
+      <nut-tab-panel tab-title="页签6">页签6</nut-tab-panel>
+      <nut-tab-panel tab-title="页签7">页签7</nut-tab-panel>
+  </nut-tab>
+```
+
+```html
+  <nut-tab @tab-switch="tabSwitch" :is-scroll="true" position-nav="left">
+      <nut-tab-panel tab-title="页签1">页签1</nut-tab-panel>
+      <nut-tab-panel tab-title="页签2">页签2</nut-tab-panel>
+      <nut-tab-panel tab-title="页签3">页签3</nut-tab-panel>
+      <nut-tab-panel tab-title="页签4">页签4</nut-tab-panel>
+      <nut-tab-panel tab-title="页签5">页签5</nut-tab-panel>
+      <nut-tab-panel tab-title="页签6">页签6</nut-tab-panel>
+      <nut-tab-panel tab-title="页签7">页签7</nut-tab-panel>
+  </nut-tab>
+```
 
 ## 禁止选中,默认选中某个标签,如需更新数组后,重新渲染Tab页面,请将更新数组传入init-data
 
@@ -202,8 +227,8 @@ export default {
 | position-nav | 页签栏的分布,可选值 top/bottom/left/right | String | top
 | def-index | 默认选中的页签栏 | String | 1
 | init-data | 监听数据变化,渲染更新页面 | Array | []
-| is-show-line|是否显示tab切换时的红条|true|
-
+| is-show-line|是否显示tab切换时的红条|Boolean|true|
+| is-scroll|是否支持滑动选择多个页签|Boolean|false|
 
 ### nut-tab-panel
 

+ 150 - 94
src/packages/tab/tab.scss

@@ -1,17 +1,17 @@
-.nut-tab{
+.nut-tab {
     position: relative;
-    border:1px solid #eee;
+    border: 1px solid #eee;
     padding: 10px;
     font-size: 12px;
-    background:#eee;
-}
-.nut-tab-horizontal{
+    background: #eee;
+  }
+  .nut-tab-horizontal {
     display: flex;
     flex-direction: row;
     position: relative;
-}
-
-.close-btn{
+  }
+  
+  .close-btn {
     position: absolute;
     width: 17px;
     height: 17px;
@@ -24,8 +24,8 @@
     right: 0px;
     top: 0px;
     border-radius: 50%;
-}
-.nut-tab-horizontal .close-btn{
+  }
+  .nut-tab-horizontal .close-btn {
     position: absolute;
     width: 17px;
     height: 17px;
@@ -38,145 +38,201 @@
     right: 0px;
     top: 0px;
     border-radius: 50%;
-}
-.nut-tab-title{
+  }
+  .nut-tab-title {
     //border:1px solid #fff;
-    border-bottom:1px solid #EDEDED;
+    border-bottom: 1px solid #ededed;
     width: 100%;
     display: flex;
     height: 50px;
     line-height: 48px;
     box-sizing: border-box;
-    position: relative;   
-}
-.nav-bar{
+    position: relative;
+    overflow-x: auto;
+    overflow-y: hidden;
+    &::-webkit-scrollbar {
+        display: none;
+    }
+  }
+  .nav-bar {
     position: absolute;
     height: 2px;
-    bottom: -2px;
+    bottom: 0px;
     left: 0px;
-    background:$primary-color;
-    transition: all 0.4s ease-in-out;
-}
-.nut-tab-title-leftnav{
-    border-right:1px solid #EDEDED;
+    z-index: 2;
+    background: $primary-color;
+    transition: all 0.3s ease-in-out;
+  }
+  .nut-tab-title-leftnav {
+    border-right: 1px solid #ededed;
     width: 100px;
     display: flex;
     background: #fff;
-    flex-direction: column; 
+    flex-direction: column;
     position: relative;
-    .nav-bar-left{
-        position: absolute;
-        width: 2px;
-        right: -2px;
-        top: 0px;
-        background:$primary-color;
-        transition: all 0.4s ease-in-out;
+    height: 200px;
+    overflow-y: auto;
+    overflow-x: hidden;
+    &::-webkit-scrollbar {
+        display: none;
+    }
+    .nav-bar-left {
+      position: absolute;
+      width: 2px;
+      right: 0px;
+      top: 0px;
+      z-index: 2;
+      background: $primary-color;
+      transition: all 0.3s ease-in-out;
     }
-    .nut-title-nav{
-        border:0;
-        border-left:1px solid #F5F7FA;
+    .nut-title-nav {
+      border: 0;
+      border-left: 1px solid #f5f7fa;
     }
-    .nut-tab-active{
-        background: #fff;
+    .nut-tab-active {
+      background: #fff;
+    //   a{
+    //     color: red;
+    //   }
     }
-}
-.nut-tab-title-rightnav{
+  }
+  .nut-tab-title-rightnav {
     background: #fff;
-    border:1px solid #fff;
-    border-left:1px solid #EDEDED;
+    // border: 1px solid #fff;
+    border-left: 1px solid #ededed;
     width: 100px;
     display: flex;
-    flex-direction: column; 
+    flex-direction: column;
     position: relative;
-    .nav-bar-right{
-        position: absolute;
-        width: 2px;
-        left: -2px;
-        top: 0px;
-        background:$primary-color;
-        transition: all 0.4s ease-in-out;
+    overflow-y: auto;
+    overflow-x: hidden;
+    height: 200px;
+    box-sizing: border-box;
+    &::-webkit-scrollbar {
+        display: none;
+    }
+    .nav-bar-right {
+      position: absolute;
+      width: 2px;
+      left: 0px;
+      top: 0px;
+      z-index:2;
+      background: $primary-color;
+      transition: all 0.3s ease-in-out;
     }
-}
-.nut-tab-link{
+  }
+  .nut-tab-link {
     color: #333;
     display: flex;
-    align-items:center;
-    justify-content:center;
-    font-size:12px;
-    text-decoration:none;
+    align-items: center;
+    justify-content: center;
+    font-size: 12px;
+    text-decoration: none;
     line-height: 1;
-}
-.nut-tab-title-bottomnav{
-    border:1px solid #fff;
-    border-top:1px solid #EDEDED;
+    width: 100%;
+    height:100%;
+  }
+  .nut-tab-title-bottomnav {
+    border: 1px solid #fff;
+    border-top: 1px solid #ededed;
     width: 100%;
     display: flex;
     height: 50px;
-    line-height: 49px; 
+    line-height: 49px;
     box-sizing: border-box;
     position: relative;
-    .nav-bar-bottom{
-        position: absolute;
-        height: 2px;
-        left: 0px;
-        top: -2px;
-        background:$primary-color;
-        transition: all 0.4s ease-in-out;
+    overflow-x: auto;
+    overflow-y: hidden;
+    &::-webkit-scrollbar {
+        display: none;
     }
-}
-
-.nut-title-nav-list{
+    .nav-bar-bottom {
+      position: absolute;
+      height: 2px;
+      left: 0px;
+      top: 0px;
+      z-index: 2;
+      background: $primary-color;
+      transition: all 0.3s ease-in-out;
+    }
+  }
+  
+  .nut-title-nav-list {
     flex: 1;
     position: relative;
     flex-direction: row;
-    align-items:center;
-    justify-content:center;
+    align-items: center;
+    justify-content: center;
     display: flex;
     background: #fff;
     box-sizing: border-box;
-}
-.nut-title-nav-leftnav{
-    flex:1;
+  }
+  .nut-title-nav-leftnav {
+    flex: 1;
     display: flex;
     padding-left: 5px;
     //justify-content: center;
     align-items: center;
     position: relative;
-}
-.nut-title-nav-rightnav{
-    flex:1;
+  }
+  .nut-title-nav-rightnav {
+    flex: 1;
     display: flex;
     padding-right: 5px;
     justify-content: flex-end;
     align-items: center;
     position: relative;
-}
-.nut-tab-icon{
+  }
+  .nut-title-nav-scroll{
+    min-width: 100px;
+    position: relative;
+    flex-direction: row;
+    align-items: center;
+    justify-content: center;
+    display: flex;
+    background: #fff;
+    box-sizing: border-box;
+  }
+  .nut-title-vertical-scroll{
+    min-height: 55px;
+    position: relative;
+    flex-direction: row;
+    align-items: center;
+    justify-content: center;
+    display: flex;
+    background: #fff;
+    box-sizing: border-box;
+  }
+  .nut-tab-icon {
     display: inline-block;
     margin-right: 5px;
     width: 20px;
     height: 20px;
-    background-repeat: no-repeat; 
-    background-size:100% 100%;
-}
-.nut-tab-active{
+    background-repeat: no-repeat;
+    background-size: 100% 100%;
+  }
+  .nut-tab-active {
     background: #fff;
     border: 0;
-}
-.nut-tab-item {  
+    // a{
+    //     color: red;
+    // }
+  }
+  .nut-tab-item {
     height: 200px;
-    border:1px solid #fff;
-    background:#fff;
+    border: 1px solid #fff;
+    background: #fff;
     width: 100%;
     padding: 10px;
     box-sizing: border-box;
-    .hide{
-        display: none;
+    .hide {
+      display: none;
     }
-}
-.nut-tab-disable{
+  }
+  .nut-tab-disable {
     background: #e1e1e1 !important;
-}
-.tabbar-nav-word{
-    font-size:$font-size-small;
-}
+  }
+  .tabbar-nav-word {
+    font-size: $font-size-small;
+  }
+  

+ 183 - 184
src/packages/tab/tab.vue

@@ -1,200 +1,199 @@
 <template>
-    <div class="nut-tab-part" >
-        <div class="nut-tab" :class="{'nut-tab-horizontal' : positionNavCss}">
-            <div v-if="positionNav=='right' || positionNav=='bottom'" class="nut-tab-item" ref="items">
-                <slot></slot>
-            </div>
-            <div :class="titleCLass">
-                <b v-if="isShowLine" :class="navBarClass" :style="navBarStyle"></b>
-                <span 
-                    v-for="(value,index) in tabTitleList"  
-                    :key="index"
-                    :class="[titleNavList,'nut-title-nav',{'nut-tab-disable':value.disable},{'nut-tab-active' : activeIndex == index}]"
-                >
-                    <a class="nut-tab-link" v-on:click="switchTab(index,$event,value.disable)">
-                        <i class="nut-tab-icon" :style="{backgroundImage: 'url('+value.iconUrl+')'}" v-if="value.iconUrl"></i>
-                        {{value.tabTitle}}
-                    </a>
-                </span>
-            </div>
-            <div v-if="positionNav=='top' || positionNav=='left'" class="nut-tab-item" ref="items">
-                <slot></slot>
-            </div>  
-        </div>
+  <div class="nut-tab-part">
+    <div class="nut-tab" :class="{ 'nut-tab-horizontal': positionNavCss }">
+      <div v-if="positionNav == 'right' || positionNav == 'bottom'" class="nut-tab-item" ref="items">
+        <slot></slot>
+      </div>
+      <div :class="titleCLass" ref="navlist">
+        <b v-if="isShowLine" :class="navBarClass" :style="navBarStyle"></b>
+        <span
+          v-for="(value, index) in tabTitleList"
+          :key="index"
+          :class="[titleNavList, 'nut-title-nav', { 'nut-tab-disable': value.disable }, { 'nut-tab-active': activeIndex == index }]"
+        >
+          <a class="nut-tab-link" v-on:click="switchTab(index, $event, value.disable)">
+            <i class="nut-tab-icon" :style="{ backgroundImage: 'url(' + value.iconUrl + ')' }" v-if="value.iconUrl"></i>
+            {{ value.tabTitle }}
+          </a>
+        </span>
+      </div>
+      <div v-if="positionNav == 'top' || positionNav == 'left'" class="nut-tab-item" ref="items">
+        <slot></slot>
+      </div>
     </div>
+  </div>
 </template>
 <script>
 export default {
-    name:'nut-tab',
-    props: {
-        'isShowLine':{
-            type:Boolean,
-            default:true
-        },
-        'defIndex':{
-            type:Number,
-            default:0
-        },
-        'positionNav':{
-            type:String,
-            default:'top'
-        },
-        'initData':{
-            type:Array,
-            default:function(){
-                return [];
-            }
-        }     
+  name: 'nut-tab',
+  props: {
+    isScroll:{
+        type:Boolean,
+        default:false
+    },
+    isShowLine: {
+      type: Boolean,
+      default: true
+    },
+    defIndex: {
+      type: Number,
+      default: 0
+    },
+    positionNav: {
+      type: String,
+      default: 'top'
+    },
+    initData: {
+      type: Array,
+      default: function() {
+        return [];
+      }
+    }
+  },
+  data() {
+    return {
+      tabTitleList: [],
+      activeIndex: this.defIndex,
+      initX: '0',
+      navWidth: 0
+    };
+  },
+  watch: {
+    defIndex() {
+      this.updeteTab();
+    },
+    initData: {
+      handler() {
+        this.updeteTab();
+      },
+      deep: true
+    }
+  },
+  computed: {
+    //下面有些样式名称是为了兼容之前的版本
+    positionNavCss: function() {
+      if (this.positionNav === 'left' || this.positionNav === 'right') return true;
+    },
+    titleCLass: function() {
+      if (this.positionNav == 'top') {
+        return 'nut-tab-title';
+      }
+      return 'nut-tab-title-' + this.positionNav + 'nav';
     },
-    data() {
+    navBarClass: function() {
+      if (this.positionNav == 'top') {
+        return 'nav-bar';
+      }
+      return 'nav-bar-' + this.positionNav;
+    },
+    titleNavList: function() {
+      if (this.positionNav == 'top' || this.positionNav == 'bottom') {
+        if(this.isScroll){
+            return 'nut-title-nav-scroll';
+        }
+        return 'nut-title-nav-list';
+      }else{
+        if(this.isScroll){
+            return 'nut-title-vertical-scroll';
+        }
+        return 'nut-title-nav-' + this.positionNav + 'nav';
+      }
+      
+    },
+    navBarStyle: function() {
+    if (this.positionNav === 'top' || this.positionNav === 'bottom') {
         return {
-            tabTitleList:[],
-            activeIndex:this.defIndex,
-            initX:'0',
-            navWidth:0,
+          transform: `translateX(${this.initX}px)`,
+          width: this.navWidth + 'px'
         };
+    }
+    return {
+        transform: `translateY(${this.initX}px)`,
+        height: this.navWidth + 'px'
+    };
+    }
+  },
+  mounted() {
+    this.$nextTick(() => {
+      this.$slots.default && this.updeteTab(this.$slots.default);
+    });
+  },
+  methods: {
+    updeteTab: function() {
+      this.$nextTick(() => {
+        this.tabTitleList = [];
+        this.activeIndex = this.defIndex;
+        this.initTab([...this.$slots.default]);
+      });
     },
-    watch:{
-        defIndex(){
-            this.updeteTab();
-        },
-       initData:{
-           handler(){
-            this.updeteTab();
-           },
-           deep:true
-       }
-    },
-    computed:{
-        //下面有些样式名称是为了兼容之前的版本
-        positionNavCss:function(){
-            if(this.positionNav==='left' || this.positionNav==='right') return true;
-        },
-        titleCLass:function() {
-            if(this.positionNav == 'top'){
-                return "nut-tab-title"
-            }
-            return "nut-tab-title-" + this.positionNav +"nav";
-        },
-        navBarClass:function() {
-            if(this.positionNav == 'top'){
-                return "nav-bar"
-            }
-            return "nav-bar-"+ this.positionNav;
-        },
-        titleNavList:function(){
-            if(this.positionNav == 'top' || this.positionNav == 'bottom'){
-                return "nut-title-nav-list"
-            }
-            return "nut-title-nav-"+ this.positionNav + 'nav';
-        },
-        navBarStyle:function(){
-            if(this.positionNav==="top"||this.positionNav==="bottom"){
-                return  {
-                    "transform": `translateX(${this.initX}px)`,
-                    "width": this.navWidth+'px'
-                }
-            }else{
-                return  {
-                    "transform": `translateY(${this.initX}px)`,
-                    "height": this.navWidth+'px'
-                }
+    initTab: function(slot) {
+      for (let i = 0; i < slot.length; i++) {
+        let slotTag = slot[i].tag;
+        if (typeof slotTag == 'string' && slotTag.indexOf('nut-tab-panel') != -1) {
+          let attrs = slot[i].data.attrs;
+          let item = {
+            tabTitle: attrs['tab-title'] || attrs['tabTitle'],
+            disable: attrs.disable === false,
+            iconUrl: attrs['iconUrl'] || attrs['icon-url']
+          };
+          this.tabTitleList.push(item);
+          let slotElm = slot[i].elm;
+          if (slotElm) {
+              slotElm.classList.add('hide');
+            if (this.activeIndex == i) {
+              slotElm.classList.remove('hide');
             }
+          }
+        }
+      }
+      this.$nextTick(() => {
+        if (this.positionNav == 'top' || this.positionNav == 'bottom') {
+            this.navWidth = this.$refs.navlist.querySelector('.nut-title-nav').offsetWidth;
+        }else{
+            this.navWidth = this.$refs.navlist.querySelector('.nut-title-nav').offsetHeight;
         }
+        this.initX = parseInt(this.navWidth * this.defIndex);
+      });
     },
-    mounted() {
-        this.$nextTick(()=>{
-            this.$slots.default && this.updeteTab(this.$slots.default); 
-        })     
+    getStyle: function(obj, styleName) {
+      if (!obj) {
+        return '';
+      }
+      if (obj.currentStyle) {
+        return obj.currentStyle[styleName];
+      } else {
+        return getComputedStyle(obj, null)[styleName];
+      }
     },
-    methods: {
-        updeteTab:function(){  
-            this.$nextTick(()=>{;
-                this.tabTitleList = [];
-                this.activeIndex = this.defIndex;
-                this.initTab([...this.$slots.default]);  
-            });
-        },
-        initTab:function(slot){
-            for(let i = 0; i < slot.length; i++) {
-                let slotTag = slot[i].tag;
-                if(typeof(slotTag)=='string' && slotTag.indexOf('nut-tab-panel') != -1) {
-                    let attrs = slot[i].data.attrs;
-                    let item ={
-                        'tabTitle':attrs['tab-title'] || attrs['tabTitle'],
-                        'disable':attrs.disable===false,
-                        'iconUrl':attrs['iconUrl'] || attrs['icon-url'],
-                    }
-                    this.tabTitleList.push(item);
-                    let slotElm = slot[i].elm;
-                    if(slotElm){
-                        slotElm.classList.add('hide');
-                        if(this.activeIndex == i) {
-                            slotElm.classList.remove('hide');
-                        }
-                    }                
-                }
-            }
-            this.$nextTick(()=>{
-                this.getTabWidth();
-            })
-        },
-        getStyle:function(obj,styleName){
-            if(!obj){
-                return ''
-            }
-            if(obj.currentStyle){
-                return obj.currentStyle[styleName];
-            }else{
-                return getComputedStyle(obj,null)[styleName];
-            }
-        },
-        getTabWidth:function(){
-            if(this.positionNav=='top' || this.positionNav=='bottom'){
-                let tabTitle = document.querySelector('.nut-tab-title');
-                let tabWidth = this.getStyle(tabTitle,'width');
-                this.setInitX(tabWidth);
-            }else{
-                let tabTitle = document.querySelector('.nut-tab-title-leftnav')|| document.querySelector('.nut-tab-title-rightnav');
-                let tabWidth = this.getStyle(tabTitle,'height');
-                this.setInitX(tabWidth);
-            }
-        },
-        setInitX(tabWidth){
-            let tabWidthNum = tabWidth.substring(0,tabWidth.length-2);
-            let navBarWidth = (tabWidthNum/this.tabTitleList.length);
-            this.navWidth = navBarWidth;
-            this.initX= parseInt(this.navWidth * this.defIndex);
-        },
-        findParent(event,myclass){
-            let parentCpt = event.target;
-            let flag = 0;//避免死循环
-            while (parentCpt && flag<10) {
-                flag++;
-                if (parentCpt.className && parentCpt.className === myclass) {
-                   break;
-                }
-                parentCpt = parentCpt.parentNode;
-            }
-            return parentCpt;
-        },
-        switchTab:function(index,event,disable){
-            if(!disable){
-                this.activeIndex=index;
-                this.initX= parseInt(this.navWidth * index);
-                let nutTab = this.findParent(event,'nut-tab-part');
-                let items = this.$refs.items.children;
-                for(let i=0;i<items.length;i++){
-                    if(i==index){
-                        items[i].classList.remove('hide');
-                    }else{
-                        items[i].classList.add('hide');
-                    }
-                }
-                this.$emit('tab-switch',index,event); 
-                this.$emit('tabSwitch',index,event); //兼容以前驼峰法命名
-            }
+    findParent(event, myclass) {
+      let parentCpt = event.target;
+      let flag = 0; //避免死循环
+      while (parentCpt && flag < 10) {
+        flag++;
+        if (parentCpt.className && parentCpt.className === myclass) {
+          break;
+        }
+        parentCpt = parentCpt.parentNode;
+      }
+      return parentCpt;
+    },
+    switchTab: function(index, event, disable) {
+      if (!disable) {
+        this.activeIndex = index;
+        this.initX = parseInt(this.navWidth * index);
+        let nutTab = this.findParent(event, 'nut-tab-part');
+        let items = this.$refs.items.children;
+        for (let i = 0; i < items.length; i++) {
+          if (i == index) {
+            items[i].classList.remove('hide');
+          } else {
+            items[i].classList.add('hide');
+          }
         }
+        this.$emit('tab-switch', index, event);
+        this.$emit('tabSwitch', index, event); //兼容以前驼峰法命名
+      }
     }
-}
+  }
+};
 </script>