el-plus 菜单配置

<template>
   <el-container class="container1">
    <el-aside width="collapse">
  <el-row class="tac">
    <el-col :span="12">
      <el-menu
        :collapse-transition="false"
        :collapse="iscollapse"
        active-text-color="#ffd04b"
        background-color="#545c64"
        class="el-menu-vertical-demo"
        default-active="2"
        text-color="#fff"
        @open="handleOpen"
        @close="handleClose"
      >
        <el-sub-menu index="1">
          <template #title>
            <i class="el-icon"><svg viewBox="0 0 48 48" fill="none"><path d="M9 18V42H39V18L24 6L9 18Z" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"></path><path d="M19 29V42H29V29H19Z" fill="none" stroke="currentColor" stroke-width="4" stroke-linejoin="round"></path><path d="M9 42H39" stroke="currentColor" stroke-width="4" stroke-linecap="round"></path></svg></i>
            <span>Dashboard</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="1-1"><i class="el-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M544 768v128h192a32 32 0 1 1 0 64H288a32 32 0 1 1 0-64h192V768H192A128 128 0 0 1 64 640V256a128 128 0 0 1 128-128h640a128 128 0 0 1 128 128v384a128 128 0 0 1-128 128zM192 192a64 64 0 0 0-64 64v384a64 64 0 0 0 64 64h640a64 64 0 0 0 64-64V256a64 64 0 0 0-64-64z"></path></svg></i>工作台</el-menu-item>
            <el-menu-item index="1-2"><i class="el-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="m665.216 768 110.848 192h-73.856L591.36 768H433.024L322.176 960H248.32l110.848-192H160a32 32 0 0 1-32-32V192H64a32 32 0 0 1 0-64h896a32 32 0 1 1 0 64h-64v544a32 32 0 0 1-32 32zM832 192H192v512h640zM352 448a32 32 0 0 1 32 32v64a32 32 0 0 1-64 0v-64a32 32 0 0 1 32-32m160-64a32 32 0 0 1 32 32v128a32 32 0 0 1-64 0V416a32 32 0 0 1 32-32m160-64a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V352a32 32 0 0 1 32-32"></path></svg></i>分析页</el-menu-item>
            <el-menu-item index="1-3"><i class="el-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768m0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896"></path><path fill="currentColor" d="M192 512a320 320 0 1 1 640 0 32 32 0 1 1-64 0 256 256 0 1 0-512 0 32 32 0 0 1-64 0"></path><path fill="currentColor" d="M570.432 627.84A96 96 0 1 1 509.568 608l60.992-187.776A32 32 0 1 1 631.424 440l-60.992 187.776zM502.08 734.464a32 32 0 1 0 19.84-60.928 32 32 0 0 0-19.84 60.928"></path></svg></i>监控页</el-menu-item>
          </el-menu-item-group>
        </el-sub-menu>
        <el-menu-item index="2">
          <i class="el-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M600.704 64a32 32 0 0 1 30.464 22.208l35.2 109.376c14.784 7.232 28.928 15.36 42.432 24.512l112.384-24.192a32 32 0 0 1 34.432 15.36L944.32 364.8a32 32 0 0 1-4.032 37.504l-77.12 85.12a357.12 357.12 0 0 1 0 49.024l77.12 85.248a32 32 0 0 1 4.032 37.504l-88.704 153.6a32 32 0 0 1-34.432 15.296L708.8 803.904c-13.44 9.088-27.648 17.28-42.368 24.512l-35.264 109.376A32 32 0 0 1 600.704 960H423.296a32 32 0 0 1-30.464-22.208L357.696 828.48a351.616 351.616 0 0 1-42.56-24.64l-112.32 24.256a32 32 0 0 1-34.432-15.36L79.68 659.2a32 32 0 0 1 4.032-37.504l77.12-85.248a357.12 357.12 0 0 1 0-48.896l-77.12-85.248A32 32 0 0 1 79.68 364.8l88.704-153.6a32 32 0 0 1 34.432-15.296l112.32 24.256c13.568-9.152 27.776-17.408 42.56-24.64l35.2-109.312A32 32 0 0 1 423.232 64H600.64zm-23.424 64H446.72l-36.352 113.088-24.512 11.968a294.113 294.113 0 0 0-34.816 20.096l-22.656 15.36-116.224-25.088-65.28 113.152 79.68 88.192-1.92 27.136a293.12 293.12 0 0 0 0 40.192l1.92 27.136-79.808 88.192 65.344 113.152 116.224-25.024 22.656 15.296a294.113 294.113 0 0 0 34.816 20.096l24.512 11.968L446.72 896h130.688l36.48-113.152 24.448-11.904a288.282 288.282 0 0 0 34.752-20.096l22.592-15.296 116.288 25.024 65.28-113.152-79.744-88.192 1.92-27.136a293.12 293.12 0 0 0 0-40.256l-1.92-27.136 79.808-88.128-65.344-113.152-116.288 24.96-22.592-15.232a287.616 287.616 0 0 0-34.752-20.096l-24.448-11.904L577.344 128zM512 320a192 192 0 1 1 0 384 192 192 0 0 1 0-384m0 64a128 128 0 1 0 0 256 128 128 0 0 0 0-256"></path></svg></i>
          <span>系统管理</span>
        </el-menu-item>
        <el-menu-item index="3">
          <i class="el-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M832 512a32 32 0 1 1 64 0v352a32 32 0 0 1-32 32H160a32 32 0 0 1-32-32V160a32 32 0 0 1 32-32h352a32 32 0 0 1 0 64H192v640h640z"></path><path fill="currentColor" d="m469.952 554.24 52.8-7.552L847.104 222.4a32 32 0 1 0-45.248-45.248L477.44 501.44l-7.552 52.8zm422.4-422.4a96 96 0 0 1 0 135.808l-331.84 331.84a32 32 0 0 1-18.112 9.088L436.8 623.68a32 32 0 0 1-36.224-36.224l15.104-105.6a32 32 0 0 1 9.024-18.112l331.904-331.84a96 96 0 0 1 135.744 0z"></path></svg></i>
          <span>表单页面</span>
        </el-menu-item>
        <el-menu-item index="4">
          <i class="el-icon"><svg viewBox="64 64 896 896" style="transform: scale(0.88);"><path d="M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-40 208H676V232h212v136zm0 224H676V432h212v160zM412 432h200v160H412V432zm200-64H412V232h200v136zm-476 64h212v160H136V432zm0-200h212v136H136V232zm0 424h212v136H136V656zm276 0h200v136H412V656zm476 136H676V656h212v136z"></path></svg></i>
          <span>列表页面</span>
        </el-menu-item>
      </el-menu>
    </el-col>
  </el-row>
  </el-aside>
  <el-container class="container2">
    <el-header>
        <div class="container-header-icon" @click="iscollapse = !iscollapse">
        <i class="el-icon" style="transform: scale(1.15);"><svg viewBox="64 64 896 896"><path d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 000 13.8z"></path></svg></i>
        </div> 
    <HeaderPage>
    </HeaderPage>
    </el-header>
    <el-main>Main</el-main>
  </el-container>
</el-container>
</template>

<script setup>
import {ref} from 'vue';
import HeaderPage from './header/index.vue'
const iscollapse=ref(false)
const handleOpen = (key, keyPath) => {
  console.log(key, keyPath)
}
const handleClose = (key, keyPath) => {
  console.log(key, keyPath)
}
</script>

<style scoped>
.el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
}
.container1 {
    left: 0;
    top: 0;
    position: absolute;
    height: 100%;
    width: 130%;
    max-width: 1700px;
    margin: 0;
    background-color:#545c64;
    border: 1px solid #545c64;
}

.el-aside{
    line-height: 10vh;
    text-align: center;
    background-color: rgb(235, 233, 231);
    max-height: 900px;
    width: 200px;
    overflow: auto;
    box-sizing: border-box;
    flex-shrink: 0;
    width: var(--el-aside-width,100px);
}
.el-header{
    width: 100%;
    height: 54px;
    background-color:#fff;
    display: flex;

}
.el-header .container-header-icon{
    position: relative;
    height: var(--ele-header-tool-height);
    padding: 0 12px;
    display: flex;
    align-items: center;
    border-radius: var(--ele-header-tool-radius);
    transition: color .2s,background-color .2s;
    box-sizing: border-box;
    cursor: pointer;
    width: 50px;
    height: 60px;
    align-content: center;
    line-height: 30px;
    margin-left: -20px;
    /* float: left; */
}
.el-header .container-header-icon:hover{
    background: var(--ele-header-tool-hover-bg);
}
.el-main{
    width: 100%;
    height: 100%;
    background-color: rgb(42, 131, 131);
}
.container2 .container-drawer{
    width: 50px;
    height: 100%;
    line-height: 54px;
    margin-left: -25px;
}
.container2 .container-drawer .el-icon{
    --color: inherit;
    height: 1em;
    width: 1em;
    line-height: 1em;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    position: relative;
    fill: currentColor;
    color: var(--color);
    font-size: inherit;
}
.el-header .HeaderPage{
    position: relative;
    margin-left: 300px;
}
.el-menu{
  height: 100vh;
  width:8vh
}
</style>

菜单问题配置长宽还要配置aside 

以上配置是必须要的

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
对于在Vue 3中使用el-tree组件添加右键菜单,你可以按照以下步骤操作: 1. 首先,在Vue项目中安装并导入element-plus库,因为Vue 3不再支持使用element-ui。你可以使用以下命令安装element-plus: ``` npm install element-plus --save ``` 2. 在你的Vue组件中,导入el-tree组件和ContextMenu组件: ```javascript import { ElTree, ElContextMenu } from 'element-plus'; import 'element-plus/lib/theme-chalk/index.css'; ``` 3. 在你的Vue组件中,添加el-tree组件和ContextMenu组件到template中,并设置相关的属性和事件监听器: ```html <template> <div> <el-context-menu :context-menu="contextMenu"> <el-tree :data="treeData" @node-contextmenu="handleContextMenu"></el-tree> </el-context-menu> </div> </template> <script> export default { data() { return { treeData: [ // 树节点数据 ], contextMenu: [ // 右键菜单选项 ] }; }, methods: { handleContextMenu(node, event) { // 处理右键菜单点击事件 } } } </script> ``` 4. 在data中定义treeData用于展示树节点数据,contextMenu用于定义右键菜单选项。 5. 在handleContextMenu方法中,可以处理右键菜单点击事件。你可以根据需要执行相关操作。 请注意,上述代码中的treeData和contextMenu需要根据实际需求进行修改和填充。你可以根据element-plus文档中的el-tree和ContextMenu组件配置选项,来调整和自定义右键菜单的样式和功能。 希望以上信息能够帮助到你!如果你有任何其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值