Vue3+ElementUI-Plus模板menu菜单组件-二级菜单树形结构

由于使用ElementUI-plus的菜单的时候发现官方写的看不懂于是自己模拟了一个组件

我未封装改组件,需要的可以拿去自己封装,代码简单易懂,如对你有帮助请反馈。

<script setup>
import router from "@/router";
import menuArr from '../constant/aside_menu.json'
import {reactive} from "vue";
const menu=reactive([...menuArr])

</script>

<template>
  <el-menu
      mode="vertical"
  >
    <el-sub-menu :index='item.id'  v-for="(item,index) in menu">
      <template #title>
        <el-icon><ShoppingCartFull /></el-icon>
        <span>{{item.title}}</span>
      </template>
      <el-menu-item  v-for="(child,index) in item.children" :index='child.id'>{{child.title}}</el-menu-item>
    </el-sub-menu>
  </el-menu>
</template>

<style scoped>

</style>

树形结构数据

[
  {
    "id": 100,
    "title": "首页",
    "path": "/main",
    "show": false,
    "children": [
      {
        "id": 101,
        "title": "555",
        "path": "",
        "show": true
      },
      {
        "id": 102,
        "title": "666",
        "path": "",
        "show": true
      }
    ]
  },
  {
    "id": 200,
    "title": "服务器管理",
    "path": "",
    "show": true,
    "children": [
      {
        "id": 201,
        "title": "222",
        "path": "",
        "show": true
      },
      {
        "id": 202,
        "title": "333",
        "path": "/",
        "show": true
      }
    ]
  },
  {
    "id": 300,
    "title": "ces",
    "path": "",
    "show": true,
    "children": [
      {
        "id": 301,
        "title": "222",
        "path": "",
        "show": true
      },
      {
        "id": 302,
        "title": "333",
        "path": "/",
        "show": true
      }
    ]
  }



]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值