Introduction to encapsulation of Vue2.0 multi-Tab switching component

不言
Release: 2018-06-30 17:16:54
Original
2340 people have browsed it

This article mainly introduces the encapsulation example of the Vue2.0 multi-Tab switching component. The content is quite good. I will share it with you now and give it as a reference.

Vue2.0 multi-Tab switching component is simply encapsulated to meet its own simple functions and can be used directly!

First of all, the renderings:

A brief introduction to the function:

1. Support tab switching

2. Support tab positioning

3. Support tab automation

Imitate React multi-Tab implementation. In short, it can be used normally to meet daily needs.

1. Usage:

==index.vue file==

 

Copy after login

PS: TabItems is my TabSwitch component, tab page The title is the name value in p, and the two sides are the content, which can also be a subcomponent.

Next show the TabItems component

2, component

index.less file

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 { 0% { -webkit-transform: translate(110%, 0); } 100% { -webkit-transform: translate(0, 0); } } @-ms-keyframes rightMove { 0% { -ms-transform: translate(110%, 0); } 100% { -ms-transform: translate(0, 0); } } @keyframes rightMove { 0% { -webkit-transform: translate(110%, 0); -ms-transform: translate(110%, 0); transform: translate(110%, 0); } 100% { -webkit-transform: translate(0, 0); -ms-transform: translate(0, 0); transform: translate(0, 0); } }
Copy after login

TabItems.vue

  
Copy after login

PS:

created and mounted are not required for these two methods Too much introduction, Vue life cycle

1, introduction to created method.

Get the browser link address: libUtils.GetURLParamObj(); Get the browser link address

createdThis method is mainly used to locate which page the tab specifically displays

2. Introduction to mounted method

Mainly used to hide content containers

3. Tabswitch method

The page used to switch the display of the component container!

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Introduction to the development of Vue drag and drop components

Vue adds request interceptor and vue-resource Use of interceptors

The above is the detailed content of Introduction to encapsulation of Vue2.0 multi-Tab switching component. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!