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

vue elementUI使用tabs與導(dǎo)航欄聯(lián)動(dòng)

 更新時(shí)間:2019年06月21日 10:11:23   作者:yc99  
這篇文章主要為大家詳細(xì)介紹了vue elementUI使用tabs與導(dǎo)航欄聯(lián)動(dòng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

不使用tabs標(biāo)簽頁時(shí),點(diǎn)擊導(dǎo)航菜單,router-view映射相應(yīng)的組件即可顯示頁面。但我們想在點(diǎn)擊導(dǎo)航欄時(shí)在tabs中映射相應(yīng)的組件,這就需要使用tabs組件
在slider.vue中點(diǎn)擊路由后,把當(dāng)前選擇的路由@select使用bus傳出去

<el-menu class="sidebar-el-menu" :default-active="onRoutes" :collapse="collapse" background-color="#eeefef" text-color="#666" active-text-color="#20a0ff" unique-opened router @select="addTab">

 <!-- 一級(jí)菜單 -->
  <template v-for="item in slidebarData" >
  <el-submenu v-if="item.subs && item.subs.length" :index="item.index" :key="item.index">
   <template slot="title"><i :class="item.icon"></i><span>{{item.title}}</span></template>

   <!-- 二級(jí)菜單 -->
   <template v-for="itemChild in item.subs">
   <el-submenu v-if="itemChild.subs && itemChild.subs.length" :index="itemChild.index" :key="itemChild.index" class="erji">
    <template slot="title"><i :class="itemChild.icon"></i><span>{{itemChild.title}}</span></template>

    <!-- 三級(jí)菜單 -->
    <el-menu-item v-for="itemChild_Child in itemChild.subs" :index="itemChild_Child.index" :key="itemChild_Child.index">
    <i :class="itemChild_Child.icon"></i><span slot="title">{{itemChild_Child.title}}</span>
    </el-menu-item>
   </el-submenu>

   <el-menu-item v-else :index="itemChild.index" :key="itemChild.index"><i :class="itemChild.icon"></i><span slot="title">{{itemChild.title}}</span></el-menu-item>
   </template>
  </el-submenu>

  <el-menu-item v-else :index="item.index" :key="item.index"><i :class="item.icon"></i><span slot="title">{{item.title}}</span></el-menu-item>
  </template>

 </el-menu>

使用bus把路由信息傳出

import bus from '../common/bus';
methods: {
 addTab(key,keyPath) {
 console.log(key,keyPath)
 bus.$emit('navPath',keyPath)
 }
},

在tabs.vue中接收

<template>
 <div id="tabs">
 <el-tabs type="card" v-model="tabsVal" @tab-remove="closeTab" @tab-click="tabclick">
  <el-tab-pane v-for="item in tabList" :key="item.name" :name="item.name" :label="item.title" :closable="item.closable" >
        <component :is="item.component"></component>
      </el-tab-pane>
 </el-tabs>
 </div>
</template>

<script>
 import searchFor from '../page/ContentManagement/Class/searchFor.vue';
 import bus from '../common/bus';
 export default {
 data() {
  return {
  inputVisible: false,
  navPath: '',
  tabsVal: "searchFor",
  tabList: [
   {
        title: '熱門搜索',
        name: 'searchFor',
        disabled: true,
        closable: false,
        component: searchFor
      }
  ]
  }
 },
 methods: {
  closeTab(tag) {//關(guān)閉tabs
  var tabListName = []
  for(let i = 0; i < this.tabList.length; i++){
   tabListName[i] = this.tabList[i].name;
  }
  console.log(tabListName)
  this.tabList.splice(tabListName.indexOf(tag), 1);
  this.tabsVal = "searchFor";
  this.$router.push("searchFor");
  },
  tabclick(val) {
  console.log(val)
  this.$router.push(val.name);
  //點(diǎn)擊tabs觸發(fā)路由跳轉(zhuǎn),到相應(yīng)路由
  }
 },
 mounted () {
     bus.$on('navPath',(name,val) =>{//處理傳過來的值
      console.log(name)
       var titname;
       if(name[name.length -1] == 'searchFor'){
        titname = '熱門搜索'
       }else if(name[name.length -1] == 'Courier1'){
        titname = '套課列表'
       }else if(name[name.length -1] == 'Courier2'){
        titname = '小節(jié)列表'
       }else if(name[name.length -1] == 'Courier3'){
        titname = '套課分享'
       }
       if (this.tabList.filter(f => f.name == name[name.length -1]) == 0) {
        var component = resolve => require([`../page/ContentManagement/${name[0]}/${name[name.length -1]}`], resolve)//合伙人管理
        this.tabList.push({
          title: titname,
          name: name[name.length -1],
          disabled: false,
          closable: true,
          component: component
        })
       }
       this.tabsVal = name[name.length -1]
     });
    }
 }
</script>

<style scoped>
 #tabs {
 position: fixed;
 right: calc(2vw - 2px);
 top: 100px;
 z-index: 5;
 width: calc(96% - 189px);
 height: 38px;
 background: #f0f0f0;
 border-bottom: 4px solid #ccc;
 border-top: 4px solid #ccc;
 padding-left: 10px;
 }
 
 .el-tag {
 margin: 3px;
 }
 
</style>

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

相關(guān)文章

  • vue實(shí)現(xiàn)吸壁懸浮球

    vue實(shí)現(xiàn)吸壁懸浮球

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)吸壁懸浮球,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • vue中動(dòng)態(tài)組件使用及傳值方式

    vue中動(dòng)態(tài)組件使用及傳值方式

    這篇文章主要介紹了vue中動(dòng)態(tài)組件使用及傳值方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • vue打包后生成一個(gè)配置文件可以修改IP

    vue打包后生成一個(gè)配置文件可以修改IP

    本文主要介紹了修改Vue項(xiàng)目運(yùn)行的IP和端口,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-03-03
  • VueX如何實(shí)現(xiàn)數(shù)據(jù)共享

    VueX如何實(shí)現(xiàn)數(shù)據(jù)共享

    這篇文章主要介紹了VueX如何實(shí)現(xiàn)數(shù)據(jù)共享問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • elementUI組件el-dropdown(踩坑)

    elementUI組件el-dropdown(踩坑)

    本文主要介紹了elementUI組件el-dropdown的一些坑,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-12-12
  • Vue組合式API如何正確解構(gòu)props不會(huì)丟失響應(yīng)性

    Vue組合式API如何正確解構(gòu)props不會(huì)丟失響應(yīng)性

    響應(yīng)式?API?賦予了組合式?API?一大坨可能性的同時(shí),代碼精簡(jiǎn),雖然但是,我們應(yīng)該意識(shí)到響應(yīng)性的某些陷阱,比如丟失響應(yīng)性,在本文中,我們將學(xué)習(xí)如何正確解構(gòu)?Vue?組件的?props,使得?props?不會(huì)丟失響應(yīng)性
    2024-01-01
  • Vue如何設(shè)置全局css文件以及css組合器

    Vue如何設(shè)置全局css文件以及css組合器

    這篇文章主要介紹了Vue如何設(shè)置全局css文件以及css組合器問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-06-06
  • 使用Vue父子組件通信實(shí)現(xiàn)todolist的功能示例代碼

    使用Vue父子組件通信實(shí)現(xiàn)todolist的功能示例代碼

    這篇文章主要給大家介紹了關(guān)于如何使用Vue父子組件通信實(shí)現(xiàn)todolist的功能的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Vue具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • vue-seamless-scroll 實(shí)現(xiàn)簡(jiǎn)單自動(dòng)無縫滾動(dòng)且添加對(duì)應(yīng)點(diǎn)擊事件的簡(jiǎn)單整理

    vue-seamless-scroll 實(shí)現(xiàn)簡(jiǎn)單自動(dòng)無縫滾動(dòng)且添加對(duì)應(yīng)點(diǎn)擊事件的簡(jiǎn)單整理

    vue-seamless-scroll是一個(gè)基于Vue.js的簡(jiǎn)單無縫滾動(dòng)組件, 基于requestAnimationFrame實(shí)現(xiàn),配置多滿足多樣需求,目前支持上下左右無縫滾動(dòng),單步滾動(dòng),及支持水平方向的手動(dòng)切換功能,本節(jié)介紹,vue添加 vue-seamless-scroll實(shí)現(xiàn)自動(dòng)無縫滾動(dòng)的效果,并對(duì)應(yīng)添加點(diǎn)擊事件
    2023-01-01
  • Vue實(shí)現(xiàn)contenteditable元素雙向綁定的方法詳解

    Vue實(shí)現(xiàn)contenteditable元素雙向綁定的方法詳解

    contenteditable是所有HTML元素都有的枚舉屬性,表示元素是否可以被用戶編輯。本文將詳細(xì)介紹如何實(shí)現(xiàn)contenteditable元素的雙向綁定,需要的可以參考一下
    2022-05-05

最新評(píng)論

宜川县| 江津市| 凤凰县| 新巴尔虎左旗| 平罗县| 卓尼县| 旌德县| 独山县| 怀化市| 云浮市| 淮阳县| 乌拉特中旗| 闽清县| 长治市| 巴楚县| 伊春市| 威海市| 微博| 班玛县| 姜堰市| 平遥县| 神木县| 靖远县| 吉木乃县| 崇明县| 册亨县| 历史| 龙山县| 隆林| 资源县| 桐梓县| 霍林郭勒市| 中西区| 介休市| 依安县| 恩平市| 上高县| 永顺县| 仲巴县| 云阳县| 黄石市|