最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue2.0 多 Tab切換組件的封裝實(shí)例

 更新時(shí)間:2017年07月28日 11:26:04   作者:Rkatsiteli  
本篇文章主要介紹了Vue2.0 多 Tab切換組件的封裝實(shí)例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧

Vue2.0 多 Tab切換組件簡(jiǎn)單封裝,滿足自己簡(jiǎn)單的功能,可以直接拿去使用!

首先上效果圖:

功能簡(jiǎn)單介紹:

1、支持tab切換

2、支持tab定位

3、支持tab自動(dòng)化

仿React多Tab實(shí)現(xiàn),總之可以正常使用滿足日常需求,

1、使用方法:

==index.vue文件==

<TabItems>
  <div name="買入" class="first">
    <Content :isContTab = "0" />
  </div>
  <div name="自動(dòng)再平衡" class="second">
    <Content :isContTab = "1" />
  </div>
  <div name="一鍵賣出" class="three">
    <Content :isContTab = "2" />
  </div>
</TabItems>

PS:TabItems是我的TabSwitch組件,tab頁(yè)面標(biāo)題就是 div 中的name值,倆面是內(nèi)容,也可以是子組件。

接下來(lái)展示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";
    /*動(dòng)畫名稱,需要跟@keyframes定義的名稱一致*/
    -webkit-animation-duration: .3s;
    /*動(dòng)畫持續(xù)的時(shí)間長(zhǎng)*/
    -webkit-animation-iteration-count: 1;
    /*動(dòng)畫循環(huán)播放的次數(shù)為1 infinite為無(wú)限次*/
  }
}

@-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);
  }
}

TabItems.vue

<template>
  <div class="tabItems">
    <div class="Tab_tittle_wrap" @click="tabswitch">
      <span v-for="(v,i) in tabTitle" :style="{width:(100/tabTitle.length-7.5)+'%'}" :class="isShowTab==i?'router-link-active':''">{{v}}<i></i></span>
    </div>
    <div class="Tab_item_wrap">
      <slot></slot>
    </div>
  </div>
</template>

<style lang="less">
  @import "./less/index";
</style>
<script>
  export default {
    data() {
      return {
        tabTitle: [],
        isShowTab: 0,
      }
    },
    created: function() {
      let is = sessionStorage.getItem("isTabShow");
      if(is) {
        this.isShowTab = is;
      } else {
        let URL = libUtils.GetURLParamObj();
        this.isShowTab = URL.isShowTab ? URL.isShowTab : "0";
      }

      setTimeout(function() {
        this.tabswitch(document.querySelector(".Tab_tittle_wrap").children[this.isShowTab].click());
      }.bind(this), 0);
    },
    mounted() {
      let slot = this.$slots.default;
      for(let i = 0; i < slot.length; i++) {
        if(slot[i].tag == "div") {
          this.tabTitle.push(slot[i].data.attrs.name);
          if(slot[i].elm) {
            slot[i].elm.className = "hide";
            if(this.isShowTab == i) {
              slot[i].elm.className = "";
            }
          };
        }
      }
    },
    methods: {
      tabswitch() {
        if(!event) return;
        let target = event.target;

        if(target.nodeName.toLowerCase() !== 'span') {
          return;
        }

        let len = target.parentNode.children;
        for(let i = 0; i < len.length; i++) {
          len[i].index = i;
          len[i].removeAttribute('class');
        }
        target.setAttribute('class', 'router-link-active');
        this.isShowTab = target.index;

        //tabItems
        let child = this.$el.children[1].children;
        for(let k = 0; k < child.length; k++) {
          child[k].className = "hide";
          if(k == target.index) {
            child[k].className = "showAnminous";
          }
        }
        try {
          sessionStorage.setItem("isTabShow", target.index);
        } catch(err) {
          console.log(err);
        }
      }
    }
  }
</script>

PS:

created、mounted這兩個(gè)方法不需要過多介紹,Vue生命周期

1、created方法介紹。

獲取瀏覽器鏈接地址:libUtils.GetURLParamObj();獲取瀏覽器鏈接地址的

created這個(gè)方法主要是用來(lái)定位tab具體顯示哪個(gè)頁(yè)面的

2、mounted方法介紹

主要是用于隱藏內(nèi)容容器的

3、tabswitch方法

用來(lái)切換組件容器的顯示的頁(yè)面!

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • ElementPlus el-message-box樣式錯(cuò)位問題及解決

    ElementPlus el-message-box樣式錯(cuò)位問題及解決

    這篇文章主要介紹了ElementPlus el-message-box樣式錯(cuò)位問題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • VUE中v-model和v-for指令詳解

    VUE中v-model和v-for指令詳解

    本篇文章主要介紹了VUE中v-model和v-for指令詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧
    2017-06-06
  • 3種vue路由傳參的基本模式

    3種vue路由傳參的基本模式

    這篇文章主要為大家詳細(xì)介紹了vue路由傳參的3種基本模式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-02-02
  • vue中created和mounted的區(qū)別淺析

    vue中created和mounted的區(qū)別淺析

    這篇文章主要給大家介紹了關(guān)于vue中created和mounted區(qū)別的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用vue具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • vue使用vuedraggable實(shí)現(xiàn)嵌套多層拖拽排序功能

    vue使用vuedraggable實(shí)現(xiàn)嵌套多層拖拽排序功能

    這篇文章主要為大家詳細(xì)介紹了vue使用vuedraggable實(shí)現(xiàn)嵌套多層拖拽排序功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • vue中keep-alive組件實(shí)現(xiàn)多級(jí)嵌套路由的緩存

    vue中keep-alive組件實(shí)現(xiàn)多級(jí)嵌套路由的緩存

    本文主要介紹了vue中keep-alive組件實(shí)現(xiàn)多級(jí)嵌套路由的緩存,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • Vue?中插槽的使用總結(jié)

    Vue?中插槽的使用總結(jié)

    這篇文章主要向大家分享的是Vue?中插槽的使用總結(jié),包括內(nèi)容有默認(rèn)插槽、具名插槽、作用域插槽等內(nèi)容,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-04-04
  • 基礎(chǔ)的前端vite項(xiàng)目創(chuàng)建過程詳解

    基礎(chǔ)的前端vite項(xiàng)目創(chuàng)建過程詳解

    這篇文章主要介紹了如何使用Vite創(chuàng)建一個(gè)前端項(xiàng)目,并配置了Vue?Router、Vuex、Element?Plus、Axios和Element?Plus圖標(biāo)等第三方依賴,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-11-11
  • mpvue項(xiàng)目中使用第三方UI組件庫(kù)的方法

    mpvue項(xiàng)目中使用第三方UI組件庫(kù)的方法

    這篇文章主要介紹了mpvue項(xiàng)目中使用第三方UI組件庫(kù)的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧
    2018-09-09
  • 關(guān)于element-ui表頭吸附問題的解決方案

    關(guān)于element-ui表頭吸附問題的解決方案

    數(shù)據(jù)過多滑動(dòng)表格的時(shí)候,看不到表頭不知道對(duì)應(yīng)的數(shù)據(jù)是什么,用戶體驗(yàn)操作不友好,要改成表頭固定住,所以本文給大家介紹了關(guān)于element-ui表頭吸附問題的兩個(gè)解決方案,需要的朋友可以參考下
    2024-01-01

最新評(píng)論

抚顺县| 旬阳县| 岳阳县| 综艺| 铁岭市| 托里县| 乐平市| 潜江市| 蒲江县| 山西省| 察隅县| 南和县| 综艺| 福清市| 龙泉市| 阜平县| 天等县| 高邑县| 尤溪县| 岳阳市| 凉城县| 光山县| 合川市| 富顺县| 普兰县| 临洮县| 河间市| 集贤县| 香格里拉县| 永吉县| 阿拉善盟| 萨嘎县| 兰溪市| 喀喇沁旗| 安国市| 永定县| 闽侯县| 温宿县| 那坡县| 西盟| 五峰|