這是首頁進(jìn)來是高亮的
當(dāng)點(diǎn)擊消息中心,左側(cè)菜單第一個(gè)沒有高亮,刷新后可以高亮
Home.vue 文件引入左側(cè)菜單組件
<template>
<div class="home">
<el-container>
<el-header>
<el-row>
<el-col :span="4"><div class="f18 white">后臺管理系統(tǒng)</div></el-col>
<el-col :span="16">
<el-menu
:default-active="$route.path"
mode="horizontal"
@select="handleSelect"
background-color="#1f2d3d"
text-color="#fff"
active-text-color="#ffd04b" router>
<el-menu-item index="/Table">首頁</el-menu-item>
<el-submenu index="2">
<template slot="title">我的工作臺</template>
<el-menu-item index="/Form">選項(xiàng)1</el-menu-item>
<el-menu-item index="2-2">選項(xiàng)2</el-menu-item>
<el-menu-item index="2-3">選項(xiàng)3</el-menu-item>
<el-submenu index="2-4">
<template slot="title">選項(xiàng)4</template>
<el-menu-item index="2-4-1">選項(xiàng)1</el-menu-item>
<el-menu-item index="2-4-2">選項(xiàng)2</el-menu-item>
<el-menu-item index="2-4-3">選項(xiàng)3</el-menu-item>
</el-submenu>
</el-submenu>
<el-menu-item index='/User'>消息中心</el-menu-item>
<el-menu-item index="4"><a href="#" target="_blank">訂單管理</a></el-menu-item>
</el-menu>
</el-col>
<el-col :span="4" class="text-r">
<el-dropdown class="f12 white">
<span class="el-dropdown-link">
admin<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item class="f12">修改資料</el-dropdown-item>
<el-dropdown-item class="f12">修改密碼</el-dropdown-item>
<el-dropdown-item divided class="f12"><router-link to="/">退出</router-link></el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-col>
</el-row>
</el-header>
<el-container>
<el-aside>
<leftMenu ref="leftMenu"></leftMenu>
</el-aside>
<el-main>
<el-breadcrumb separator-class="el-icon-arrow-right" class="mb20">
<el-breadcrumb-item :to="{ path: '/' }">首頁</el-breadcrumb-item>
<el-breadcrumb-item>活動管理</el-breadcrumb-item>
<el-breadcrumb-item>活動列表</el-breadcrumb-item>
<el-breadcrumb-item>活動詳情</el-breadcrumb-item>
</el-breadcrumb>
<transition name="fade" mode="out-in" appear>
<router-view></router-view>
</transition>
</el-main>
</el-container>
</el-container>
</div>
</template>
<script>
import LeftMenu from './common/LeftMenu.vue'
export default {
name: 'Home',
data () {
return {
}
},
components: {
LeftMenu
},
methods: {
handleSelect (key, keyPath) {
this.$refs.leftMenu.getMenu(key) // 調(diào)用LeftMenu子組件方法
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped>
.el-breadcrumb{
font-size:12px;
}
.fade-enter-active,.fade-leave-active{
transition: opacity .5s
}
.fade-enter,.fade-leave-active{
opacity: 0;
}
</style>
LeftMenu.vue
<template>
<el-menu class="left-menu" :default-active="$route.path" background-color='#324057' text-color='#fff' :collapse="isCollapse" router>
<template v-for="secMenu in menuData">
<el-submenu index="1" class="submenu-title" :key="secMenu.id" v-if="secMenu.list">
<template slot="title">
<i class="el-icon-location"></i>
<span slot="title">{{secMenu.submenu}}</span>
</template>
<el-menu-item :index='subItem.path' v-for="subItem in secMenu.list" :key="subItem.id">{{subItem.menu}}</el-menu-item>
</el-submenu>
<el-menu-item :index="secMenu.path" :key="secMenu.id" v-else>
<i class="el-icon-menu"></i>
<span slot="title">{{secMenu.menu}}</span>
</el-menu-item>
</template>
</el-menu>
</template>
<script>
export default {
name: 'LeftMenu',
props: ['activeIndex'],
data () {
return {
isCollapse: false,
menuData: []
}
},
methods: {
handleOpen (key, keyPath) {
console.log(this.$store.state.navSelected)
console.log(key, keyPath)
},
handleClose (key, keyPath) {
console.log(key, keyPath)
},
getMenu (key) {
// console.log(key)
if (key === '/Table') {
this.menuData = [
{
menu: '首頁11',
path: '/Table',
id: 1
}
]
} else if (key === '/Form') {
this.menuData = [
{
menu: '表單1',
path: '/Form',
id: 1
},
{
menu: '表單2',
path: '/Table',
id: 2
}
]
} else {
this.menuData = [
{
menu: '消息中心1',
path: '/User',
id: 1
},
{
menu: '消息中心2',
path: '/Table',
id: 2
}
]
}
}
},
created () {
const curPathName = this.$router.history.current.name
// console.log(curPathName)
this.getMenu('/' + curPathName)
this.activeIndex = '/' + curPathName
this.$router.push(curPathName)
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped>
.el-menu-item{
width:200px;
height: 40px;
line-height: 40px;
font-size:12px;
}
</style>
路由配置文件
import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/components/Home'
import Table from '@/components/Table'
import Form from '@/components/Form'
import Login from '@/components/Login'
import User from '@/components/User'
Vue.use(Router)
const routes = [
{
path: '/',
redirect: '/Login'
},
{
path: '/Login',
component: Login
},
{
path: '/Home',
component: Home,
redirect: '/Table',
children: [
{ path: '/Table', component: Table, name: 'Table' },
{ path: '/Form', component: Form, name: 'Form' }
]
},
{
path: '/Home',
name: 'Home',
component: Home,
children: [
// 當(dāng) /user/:id/profile 匹配成功,
// UserProfile 會被渲染在 Home 的 <router-view> 中
{ path: '/User', component: User, name: 'User' }
]
}
]
export default new Router({
// mode: 'history', // 去掉地址中#
routes
})
如何切換頂部菜單后左側(cè)菜單也高亮 ,請指教
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
北大課工場是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國制造2025”,實(shí)現(xiàn)中華民族偉大復(fù)興的升級產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國職業(yè)人才培訓(xùn)領(lǐng)域的先行者
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。