欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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)簽頁(yè)時(shí),點(diǎn)擊導(dǎo)航菜單,router-view映射相應(yīng)的組件即可顯示頁(yè)面。但我們想在點(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 組件注冊(cè)

    詳解vue 組件注冊(cè)

    這篇文章主要介紹了vue 組件注冊(cè)的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)vue 組件的相關(guān)知識(shí),感興趣的朋友可以了解下
    2020-11-11
  • Vue 集成 storybook的方法

    Vue 集成 storybook的方法

    這篇文章主要介紹了Vue 集成 storybook的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-12-12
  • vue 內(nèi)置過濾器的使用總結(jié)(附加自定義過濾器)

    vue 內(nèi)置過濾器的使用總結(jié)(附加自定義過濾器)

    這篇文章主要介紹了vue 內(nèi)置過濾器的使用總結(jié)(附加自定義過濾器),詳細(xì)的介紹了各種過濾器的使用,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-12-12
  • vue和react中關(guān)于插槽詳解

    vue和react中關(guān)于插槽詳解

    這篇文章主要介紹了vue和react中關(guān)于插槽詳解,slot插槽是Vue對(duì)組件嵌套這種擴(kuò)展機(jī)制的稱謂,在react可以也這樣稱呼,但是并不很常見。不過叫slot確實(shí)很形象
    2022-08-08
  • vuex安裝失敗解決的方法實(shí)例

    vuex安裝失敗解決的方法實(shí)例

    Vuex是一個(gè)專為Vue.js應(yīng)用程序開發(fā)的狀態(tài)管理模式,下面這篇文章主要給大家介紹了關(guān)于vuex安裝失敗解決的方法,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2022-07-07
  • vue腳手架搭建項(xiàng)目的兼容性配置詳解

    vue腳手架搭建項(xiàng)目的兼容性配置詳解

    這篇文章主要介紹了vue腳手架搭建項(xiàng)目的兼容性配置詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-07-07
  • 關(guān)于eslint和prettier格式化沖突問題

    關(guān)于eslint和prettier格式化沖突問題

    這篇文章主要介紹了eslint和prettier格式化沖突問題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-08-08
  • vue多功能渲染函數(shù)h()的使用和多種應(yīng)用場(chǎng)景

    vue多功能渲染函數(shù)h()的使用和多種應(yīng)用場(chǎng)景

    我們?cè)趘ue項(xiàng)目里面用HTML標(biāo)簽構(gòu)建頁(yè)面時(shí)最終會(huì)被轉(zhuǎn)化成vnode,而h()是直接創(chuàng)建vnode,因此h()能以一種更靈活的方式在各種各樣情景下構(gòu)建組件的渲染邏輯,并且能帶來性能方式的提升,本文介紹如何使用和列出具體的應(yīng)用場(chǎng)景,需要的朋友可以參考下
    2024-08-08
  • Vue中computed屬性和watch,methods的區(qū)別

    Vue中computed屬性和watch,methods的區(qū)別

    本文主要介紹了Vue中computed屬性和watch,methods的區(qū)別,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-05-05
  • vue-cli webpack2項(xiàng)目打包優(yōu)化分享

    vue-cli webpack2項(xiàng)目打包優(yōu)化分享

    下面小編就為大家分享一篇vue-cli webpack2項(xiàng)目打包優(yōu)化,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-02-02

最新評(píng)論