vue管理布局左侧菜单栏NavMenu

我们接着上回的写,我们写一下左侧的菜单

复制代码
<el-aside style="width: 200px;">
        <div
          style="height: 60px;display: flex;align-items: center;justify-content: center;background-color: #ccc;color: white;">
          logo
        </div>
        <el-menu>
          <el-menu-item>系统首页</el-menu-item>
          <el-menu-item>系统首页</el-menu-item>
          <el-menu-item>系统首页</el-menu-item>
          <el-submenu>
            <template slot="title">
              <i class="el-icon-menu"></i><span>信息管理</span>
            </template>
            <el-menu-item>系统首页</el-menu-item>
            <el-menu-item>系统首页</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>

这就是左侧的代码,我加了一点样式,因为正常的都是上面有一个logo,下面再写菜单栏,我们写一下这个el-menu

首先写一个el-menu,这个显然就是一级菜单,然后在里面写el-menu-item写出几项就可以了,然后我们再继续写二级菜单,就是el-submenu,这个东西吧,你可以在里面直接谢日el-menu-item,但是,你想在二级菜单上写字,就必须要用到template这个标签,然后就在里面添加slot属性,接着写一个图标➕一点字,就可以实现二级菜单的title了。

我们一级菜单也可以实现这样的效果

复制代码
<el-aside style="width: 200px;">
        <div
          style="height: 60px;display: flex;align-items: center;justify-content: center;background-color: #ccc;color: white;">
          logo
        </div>
        <el-menu>
          <el-menu-item>
            <template slot="title">
              <i class="el-icon-house"></i><span>系统首页</span>
            </template>
          </el-menu-item>
          <el-menu-item>系统首页</el-menu-item>
          <el-menu-item>系统首页</el-menu-item>
          <el-submenu>
            <template slot="title">
              <i class="el-icon-menu"></i><span>信息管理</span>
            </template>
            <el-menu-item>系统首页</el-menu-item>
            <el-menu-item>系统首页</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>

我们写完了发现一个问题,就是右侧有一个下拉条,这个下拉条太丑了吧!我们得想办法给他弄掉

我们给el-aside设置一个最小高度就可以了min-width: 100vh;

我们还看到旁边还有一个边框也很难看,直接去掉!border: none

复制代码
<el-aside style="width: 200px;min-height: 100vh;">
        <div
          style="height: 60px;width: 200px;display: flex;align-items: center;justify-content: center;background-color: #ccc;color: white;">
          logo
        </div>
        <el-menu style="border: none;">
          <el-menu-item>
            <template slot="title">
              <i class="el-icon-house"></i><span>系统首页</span>
            </template>
          </el-menu-item>
          <el-menu-item>系统首页</el-menu-item>
          <el-menu-item>系统首页</el-menu-item>
          <el-submenu>
            <template slot="title">
              <i class="el-icon-menu"></i><span>信息管理</span>
            </template>
            <el-menu-item>系统首页</el-menu-item>
            <el-menu-item>系统首页</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>

这样就可以去掉边框和下拉条了!

相关推荐
hunterandroid13 分钟前
HarmonyOS 弱网与离线优先架构实战:请求队列、本地缓存与增量同步
前端·前端框架
lhldsg18 分钟前
宠物同城领养平台开发实战:从需求分析到上线部署指南
java·前端·小程序·需求分析·宠物
hunterandroid18 分钟前
Android 内存泄漏排查实战:从 LeakCanary 报警到根因定位
android·前端
AI视觉网奇19 分钟前
3d子部件高亮选中
开发语言·javascript·3d
leoZ23120 分钟前
AI+前端提效-12 AI辅助前端性能优化与监控:从开发到线上全流程提效
前端·人工智能·神经网络·自然语言处理·性能优化·keras·知识图谱
阿图灵22 分钟前
LangGraph 实战 03:Workflows 与 Agents——六种工作流模式与智能体实战(附 6 个可运行示例)
java·前端·javascript·工作流·ai agent·智能体·langgraph
狂炫冰美式27 分钟前
电脑合盖之后 Cursor 还在偷我电?看看为啥
前端·人工智能·后端
leeyi27 分钟前
微前端:14 个子应用是怎么做到不散架的——DeepFlux 前端工程拆解(第102篇)
前端·aigc·agent
2603_965896621 小时前
JavaScript 对象零基础详解|属性、方法、遍历、增删改查
开发语言·javascript·ecmascript
天道kabuto1 小时前
踩坑实录:JS Map迭代器为什么“用完即焚”?兼谈技术知识沉淀
前端