基于el-menu 导航栏学习(1)
对于导航栏主菜单NavMenuDemo.vue进行for循环改进,代码如下所示:
:default-active="this.$route.path" class="el-menu-demo" router @select="handleSelect" > {{ item.navItem }}
export default({
data() {
return {
navList: [
{ name: "/test1", navItem: "导航一" },
{ name: "/test2", navItem: "导航二" },
{ name: "/test3", navItem: "导航三" },
],
};
},
methods:{
handleSelect(key, keyPath) {
console.log(key, keyPath);
},
}
})
.el-aside {
height: 100vh;
text-align: center;
}
.el-main {
background-color: #E9EEF3;
}