Vue2.0 多 Tab切换组件的封装实例

2020-06-13 10:43:38易采站长站整理

Vue2.0 多 Tab切换组件简单封装,满足自己简单的功能,可以直接拿去使用!

首先上效果图:

功能简单介绍:

1、支持tab切换

2、支持tab定位

3、支持tab自动化

仿React多Tab实现,总之可以正常使用满足日常需求,

1、使用方法:

==index.vue文件==


<TabItems>
<div name="买入" class="first">
<Content :isContTab = "0" />
</div>
<div name="自动再平衡" class="second">
<Content :isContTab = "1" />
</div>
<div name="一键卖出" class="three">
<Content :isContTab = "2" />
</div>
</TabItems>

PS:TabItems是我的TabSwitch组件,tab页面标题就是 div 中的name值,俩面是内容,也可以是子组件。

接下来展示TabItems组件

2、组件

index.less文件


body,html {margin: 0;}

* {
opacity: 1;
-webkit-backface-visibility: hidden;
}

.tabItems {
.Tab_tittle_wrap {
position: absolute;
width: 100%;
top: 0;
z-index: 2;
background: @ffffff;
display: -webkit-box;
height: 80px;
line-height: 80px;
text-align: center;
color: @222222;
border-bottom: 1px solid rgba(46, 177, 255, 0.08);
box-shadow: 0px 0px 25px 6px rgba(46, 177, 255, 0.21);
span {
display: block;
text-align: center;
width: 26%;
margin: 0 24px;
font-size: 26px;
position: relative;
i {
display: inline-block;
position: absolute;
width: 1px;
height: 50px;
top: 15px;
right: -24px;
background: @dddddd;
}
&:last-child {
i {
display: none;
}
}
}
.router-link-active {
color: #8097f9;
border-bottom: 1px solid #8097f9;
}
}
.Tab_item_wrap {
position: absolute;
top: 82px;
width: 100%;
z-index: 0;
background: @ffffff;
bottom: 0;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
}
.showAnminous {
opacity: 1;
-webkit-backface-visibility: hidden;
-webkit-animation-name: "rightMove";
/*动画名称,需要跟@keyframes定义的名称一致*/
-webkit-animation-duration: .3s;
/*动画持续的时间长*/
-webkit-animation-iteration-count: 1;
/*动画循环播放的次数为1 infinite为无限次*/
}
}

@-webkit-keyframes rightMove {