el-menu 导航栏学习-for循环封装(2)

基于el-menu 导航栏学习(1)

对于导航栏主菜单NavMenuDemo.vue进行for循环改进,代码如下所示:

<template>

<el-container>

<el-aside width="200px">

<el-menu

:default-active="this.$route.path"

class="el-menu-demo"

router

@select="handleSelect"

>

<el-menu-item v-for="(item, i) in navList" :key="i" :index="item.name">

<template slot="title">

<i class="el-icon-s-platform"></i>

<span> {{ item.navItem }}</span>

</template>

</el-menu-item>

</el-menu>

</el-aside>

<el-main>

<router-view></router-view>

</el-main>

</el-container>

</template>

<script>

export default({

data() {

return {

navList: [

{ name: "/test1", navItem: "导航一" },

{ name: "/test2", navItem: "导航二" },

{ name: "/test3", navItem: "导航三" },

],

};

},

methods:{

handleSelect(key, keyPath) {

console.log(key, keyPath);

},

}

})

</script>

<style>

.el-aside {

height: 100vh;

text-align: center;

}

.el-main {

background-color: #E9EEF3;

}

</style>

相关推荐
yyt3630458415 小时前
KlineChartQuant Tooltip 高频交互 200FPS 性能优化完整复盘
前端·经验分享·性能优化·typescript·vue·交互·chrome devtools
这里是杨杨吖1 天前
SpringBoot+Vue心理健康咨询系统 附带详细运行指导视频
spring boot·vue·心理健康
爱上纯净的蓝天3 天前
使用 AtomCode 构建微前端架构:从设计到实现实战
架构·vue·实战·react·微前端·atomcode
山海云端有限公司5 天前
随机诗词API实战:Vue项目接入完整示例与5个常见坑
vue·实战·前端开发·跨域·api调用·随机诗词api
暗冰ཏོ5 天前
Spring Boot + Vue3 订单支付模块技术实现:支付单、回调验签、幂等处理与余额扣减
前端·spring boot·后端·vue·微信支付·支付宝支付
万亿少女的梦1687 天前
基于Python的高考志愿填报辅助系统设计与实现
java·spring boot·python·mysql·vue
万亿少女的梦1687 天前
基于SpringBoot与Vue的历史博物馆展品展示与游客管理系统设计
spring boot·mysql·vue·系统设计·博物馆管理系统
衍生星球7 天前
SpringBoot3 + Vue3 + 微信小程序如何学习,以及学哪些技术,组件
sql·微信小程序·uni-app·vue·springboot
志尊宝7 天前
Vue3 环境搭建 + 第一个 HelloVue 项目(零基础入门)
vue.js·node.js·vue·css3