創(chuàng)建LeftMenu.vue
編寫client/src/components/LeftMenu.vue
,創(chuàng)建側邊導航欄:文章來源:http://www.zghlxwxcb.cn/news/detail-432180.html
<template>
<el-row class="menu_page">
<el-col>
<el-menu class="el-menu-vertical-demo"
background-color="#324057"
text-color="#fff"
active-text-color="#409eff">
<router-link to="/home">
<el-menu-item index="0">
<i class="fa fa-margin fa-server"></i>
<span slot="title">首頁</span>
</el-menu-item>
</router-link>
<template v-for="item in items">
<el-submenu v-if="item.children" :index="item.path" :key="item.path">
<template slot="title">
<i :class="'fa fa-margin '+item.icon"></i>
<span slot="title">{{item.name}}</span>
</template>
<router-link v-for="(citem,cindex) in item.children" :to="citem.path" :key="cindex">
<el-menu-item :index="citem.path">
<span slot="title">{{citem.name}}</span>
</el-menu-item>
</router-link>
</el-submenu>
</template>
</el-menu>
</el-col>
</el-row>
</template>
<script>
export default {
name: "left-menu",
data() {
return {
items: [
{
icon: "fa-money",
name: "資金管理",
path: "fund",
children: [
{
path: "fundlist", name: "資金流水"
}
]
},
{
icon: "fa-asterisk",
name: "信息管理",
path: "info",
children: [
{
path: "infoshow", name: "個人信息"
}
]
}
]
}
}
};
</script>
<style scoped>
.menu_page {
position: fixed;
top: 71px;
left: 0;
min-height: 100%;
background-color: #324057;
z-index: 99;
}
.el-menu {
border: none;
}
.fa-margin {
margin-right: 5px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
width: 180px;
min-height: 400px;
}
.el-menu-vertical-demo {
width: 35px;
}
.el-submenu .el-menu-item {
min-width: 180px;
}
.hiddenDropdown,
.hiddenDropname {
display: none;
}
a {
text-decoration: none;
}
</style>
配置Index.vue
編輯client/src/views/Index.vue
,引入側邊導航欄:文章來源地址http://www.zghlxwxcb.cn/news/detail-432180.html
<template>
<div class="index">
<HeadNav></HeadNav>
<LeftMenu></LeftMenu>
<router-view></router-view>
</div>
</template>
<script>
import HeadNav from "../components/HeadNav"
import LeftMenu from "../components/LeftMenu"
export default {
name: 'index',
components: {
HeadNav,
LeftMenu
}
};
</script>
<style>
.index {
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
到了這里,關于vue2+element-ui實現(xiàn)側邊導航欄的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!