Vue.js组件实现选项卡以及切换特效
                                            Vue.js组件实现选项卡以及切换动画特效,供大家参考,具体内容如下

创新互联专注为客户提供全方位的互联网综合服务,包含不限于做网站、成都网站建设、阿瓦提网络推广、小程序制作、阿瓦提网络营销、阿瓦提企业策划、阿瓦提品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联为所有大学生创业者提供阿瓦提建站搭建服务,24小时服务热线:18980820575,官方网址:www.cdcxhl.com
最近在学习Vue,当看梁灏大神写的《Vue.js实战》时看到了关于用组件实现选项卡功能,我也根据课后的练习加上自己的理解重新编写了一下。
组件分为pane.js和tabs.js两个部分,话不多说,直接上代码。
Document //transiton是Vue自带封装的,不懂的同学可以去找文档,主要是可以实现动画 标签一的内容 标签二的内容 标签三的内容 
//tabs.js
Vue.component('tabs', {
 template: `
 
  
  
    //pane.js
Vue.component('pane', {
 name: 'pane',
 template: `
 
    
 
 `,
 props: {
  name: {
   type: String
  },
  label: {
   type: String,
   default: ''
  },
  closable: {
   type: Boolean,
   default: true
  }
 },
 data: function () {
  return {
   show: true
  }
 },
 methods: {
  updateNav() {
   this.$parent.updateNav();
  }
 },
 watch: {
  label() {
   this.updateNav();
  }
 },
 mounted() {
  this.updateNav();
 }
})//style.css
.tabs {
 font-size: 14px;
 color: black;
}
.tabs-bar:after {
 content: '';
 display: block;
 width: 100%;
 height: 1px;
 position: relative;
 background: rgba(78, 81, 128, 0.5);
}
.tabs-tab {
 display: inline-block;
 padding: 4px 16px;
 margin-right: 6px;
 color: rgba(0, 0, 0, 0.6);
 background: rgba(134, 134, 131, 0.137);
 border: 1px solid rgba(154, 214, 248, 0.856);
 cursor: pointer;
 position: relative;
}
.tabs-tab-active {
 background: rgb(252, 251, 251);
 color: rgba(0, 0, 0, 1);
 border-top: 1px solid rgba(154, 214, 248, 0.856);
 border-bottom: 1px solid white;
}
/* .tabs-tab-active:before {
 content: '';
 display: block;
 height: 5px;
 background: grey;
 position: absolute;
 top: 0;
 left: 0;
 right: 0;
} */
.tabs-content {
 position: relative;
 left: 10px;
 top: 30px;
 padding: 8px 0;
}
/* 可以设置不同的进入和离开动画 */
/* 设置持续时间和动画函数 */
.slide-fade-enter-active {
 transition: all 1.3s ease;
}
.slide-fade-leave-active {
 transition: all 1.8s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter,
.slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */
 {
 transform: translateY(30px);
 opacity: 0;
}//text.js
var app = new Vue({
 el: '#app',
 data: {
  activeKey: '1',
 },
})以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持创新互联。
网站题目:Vue.js组件实现选项卡以及切换特效
标题网址:http://www.scyingshan.cn/article/jpiggg.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 