|
@@ -1,19 +1,20 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <div class="nut-tab">
|
|
|
|
|
- <div :class="{'nut-tab-horizontal' : positionNavCss}">
|
|
|
|
|
|
|
+ <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">
|
|
<div v-if="positionNav=='right' || positionNav=='bottom'" class="nut-tab-item" ref="items">
|
|
|
<slot></slot>
|
|
<slot></slot>
|
|
|
</div>
|
|
</div>
|
|
|
<div :class="titleCLass">
|
|
<div :class="titleCLass">
|
|
|
<b v-if="isShowLine" :class="navBarClass" :style="navBarStyle"></b>
|
|
<b v-if="isShowLine" :class="navBarClass" :style="navBarStyle"></b>
|
|
|
- <span v-for="(value,index) in tabTitleList"
|
|
|
|
|
|
|
+ <span
|
|
|
|
|
+ v-for="(value,index) in tabTitleList"
|
|
|
:key="index"
|
|
:key="index"
|
|
|
:class="[titleNavList,'nut-title-nav',{'nut-tab-disable':value.disable},{'nut-tab-active' : activeIndex == index}]"
|
|
:class="[titleNavList,'nut-title-nav',{'nut-tab-disable':value.disable},{'nut-tab-active' : activeIndex == index}]"
|
|
|
>
|
|
>
|
|
|
- <span 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}}
|
|
|
|
|
- </span>
|
|
|
|
|
|
|
+ <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>
|
|
</span>
|
|
|
</div>
|
|
</div>
|
|
|
<div v-if="positionNav=='top' || positionNav=='left'" class="nut-tab-item" ref="items">
|
|
<div v-if="positionNav=='top' || positionNav=='left'" class="nut-tab-item" ref="items">
|
|
@@ -65,17 +66,27 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
computed:{
|
|
computed:{
|
|
|
|
|
+ //下面有些样式名称是为了兼容之前的版本
|
|
|
positionNavCss:function(){
|
|
positionNavCss:function(){
|
|
|
if(this.positionNav==='left' || this.positionNav==='right') return true;
|
|
if(this.positionNav==='left' || this.positionNav==='right') return true;
|
|
|
},
|
|
},
|
|
|
titleCLass:function() {
|
|
titleCLass:function() {
|
|
|
- return "nut-tab-title-" + this.positionNav;
|
|
|
|
|
|
|
+ if(this.positionNav == 'top'){
|
|
|
|
|
+ return "nut-tab-title"
|
|
|
|
|
+ }
|
|
|
|
|
+ return "nut-tab-title-" + this.positionNav +"nav";
|
|
|
},
|
|
},
|
|
|
navBarClass:function() {
|
|
navBarClass:function() {
|
|
|
|
|
+ if(this.positionNav == 'top'){
|
|
|
|
|
+ return "nav-bar"
|
|
|
|
|
+ }
|
|
|
return "nav-bar-"+ this.positionNav;
|
|
return "nav-bar-"+ this.positionNav;
|
|
|
},
|
|
},
|
|
|
titleNavList:function(){
|
|
titleNavList:function(){
|
|
|
- return "nut-title-nav-list-"+ this.positionNav;
|
|
|
|
|
|
|
+ if(this.positionNav == 'top' || this.positionNav == 'bottom'){
|
|
|
|
|
+ return "nut-title-nav-list"
|
|
|
|
|
+ }
|
|
|
|
|
+ return "nut-title-nav-"+ this.positionNav + 'nav';
|
|
|
},
|
|
},
|
|
|
navBarStyle:function(){
|
|
navBarStyle:function(){
|
|
|
if(this.positionNav==="top"||this.positionNav==="bottom"){
|
|
if(this.positionNav==="top"||this.positionNav==="bottom"){
|
|
@@ -135,17 +146,16 @@ export default {
|
|
|
if(obj.currentStyle){
|
|
if(obj.currentStyle){
|
|
|
return obj.currentStyle[styleName];
|
|
return obj.currentStyle[styleName];
|
|
|
}else{
|
|
}else{
|
|
|
- console.log(getComputedStyle(obj,null)[styleName]);
|
|
|
|
|
return getComputedStyle(obj,null)[styleName];
|
|
return getComputedStyle(obj,null)[styleName];
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
getTabWidth:function(){
|
|
getTabWidth:function(){
|
|
|
if(this.positionNav=='top' || this.positionNav=='bottom'){
|
|
if(this.positionNav=='top' || this.positionNav=='bottom'){
|
|
|
- let tabTitle = document.querySelector('.nut-tab-title-top');
|
|
|
|
|
|
|
+ let tabTitle = document.querySelector('.nut-tab-title');
|
|
|
let tabWidth = this.getStyle(tabTitle,'width');
|
|
let tabWidth = this.getStyle(tabTitle,'width');
|
|
|
this.setInitX(tabWidth);
|
|
this.setInitX(tabWidth);
|
|
|
}else{
|
|
}else{
|
|
|
- let tabTitle = document.querySelector('.nut-tab-title-left')|| document.querySelector('.nut-tab-title-right');
|
|
|
|
|
|
|
+ let tabTitle = document.querySelector('.nut-tab-title-leftnav')|| document.querySelector('.nut-tab-title-rightnav');
|
|
|
let tabWidth = this.getStyle(tabTitle,'height');
|
|
let tabWidth = this.getStyle(tabTitle,'height');
|
|
|
this.setInitX(tabWidth);
|
|
this.setInitX(tabWidth);
|
|
|
}
|
|
}
|
|
@@ -172,7 +182,7 @@ export default {
|
|
|
if(!disable){
|
|
if(!disable){
|
|
|
this.activeIndex=index;
|
|
this.activeIndex=index;
|
|
|
this.initX= parseInt(this.navWidth * index);
|
|
this.initX= parseInt(this.navWidth * index);
|
|
|
- let nutTab = this.findParent(event,'nut-tab');
|
|
|
|
|
|
|
+ let nutTab = this.findParent(event,'nut-tab-part');
|
|
|
let items = this.$refs.items.children;
|
|
let items = this.$refs.items.children;
|
|
|
for(let i=0;i<items.length;i++){
|
|
for(let i=0;i<items.length;i++){
|
|
|
if(i==index){
|
|
if(i==index){
|