废除 menu-children-item 组件, 菜单初步支持无限极

This commit is contained in:
就眠儀式 2022-01-02 22:49:12 +08:00
parent 6d0ecc7f74
commit 923e16a5d7
5 changed files with 35 additions and 45 deletions

View File

@ -12,9 +12,13 @@
<lay-menu-item title="用户" id="2"></lay-menu-item>
<lay-menu-item title="角色" id="3"></lay-menu-item>
<lay-menu-item title="目录" id="7">
<lay-menu-child-item title="菜单一" id="4"></lay-menu-child-item>
<lay-menu-child-item title="菜单二" id="5"></lay-menu-child-item>
<lay-menu-child-item title="菜单三" id="6"></lay-menu-child-item>
<lay-menu-item title="菜单一" id="8"></lay-menu-item>
<lay-menu-item title="菜单二" id="9"></lay-menu-item>
<lay-menu-item title="菜单三" id="10">
<lay-menu-item title="菜单一" id="11"></lay-menu-item>
<lay-menu-item title="菜单二" id="12"></lay-menu-item>
<lay-menu-item title="菜单三" id="13"></lay-menu-item>
</lay-menu-item>
</lay-menu-item>
</lay-menu>
</template>
@ -52,9 +56,13 @@ export default {
<lay-menu-item title="用户" id="2"></lay-menu-item>
<lay-menu-item title="角色" id="3"></lay-menu-item>
<lay-menu-item title="目录" id="7">
<lay-menu-child-item title="菜单一" id="4"></lay-menu-child-item>
<lay-menu-child-item title="菜单二" id="5"></lay-menu-child-item>
<lay-menu-child-item title="菜单三" id="6"></lay-menu-child-item>
<lay-menu-item title="菜单一" id="8"></lay-menu-item>
<lay-menu-item title="菜单二" id="9"></lay-menu-item>
<lay-menu-item title="菜单三" id="10">
<lay-menu-item title="菜单一" id="11"></lay-menu-item>
<lay-menu-item title="菜单二" id="12"></lay-menu-item>
<lay-menu-item title="菜单三" id="13"></lay-menu-item>
</lay-menu-item>
</lay-menu-item>
</lay-menu>
</template>

View File

@ -2844,6 +2844,25 @@ body .layui-table-tips .layui-layer-content {
color: #5fb878;
}
.layui-nav .layui-show.layui-anim-upbit .layui-show.layui-anim-upbit {
top: 0px;
left: 106px;
}
.layui-nav .layui-show.layui-anim-upbit .layui-nav-item {
display: block;
height: 40px;
line-height: 40px;
}
.layui-nav .layui-show.layui-anim-upbit .layui-nav-item.layui-this {
background-color: whitesmoke;
}
.layui-nav .layui-show.layui-anim-upbit .layui-nav-item.layui-this:after {
display: none;
}
.layui-nav {
position: relative;
padding: 0 20px;
@ -2868,7 +2887,7 @@ body .layui-table-tips .layui-layer-content {
.layui-nav .layui-nav-item a {
display: block;
padding: 0 20px;
padding: 0 30px;
color: #fff;
color: rgba(255, 255, 255, 0.7);
-webkit-transition: all 0.3s;
@ -2917,7 +2936,7 @@ body .layui-table-tips .layui-layer-content {
.layui-nav .layui-nav-more {
position: absolute;
top: 0;
right: 3px;
right: 8px;
left: auto !important;
margin-top: 0;
font-size: 12.5px !important;

View File

@ -40,7 +40,6 @@ import LayContainer from "./module/container/index";
import LayCountUp from "./module/countUp/index";
import LayMenu from "./module/menu/index";
import LayMenuItem from "./module/menuItem/index";
import LayMenuChildItem from "./module/menuChildItem/index";
import LayCheckbox from "./module/checkbox/index";
import LayCheckboxGroup from "./module/checkboxGroup/index";
import LayForm from "./module/form/index";
@ -101,7 +100,6 @@ const components: Record<string, IDefineComponent> = {
LayContainer,
LayMenu,
LayMenuItem,
LayMenuChildItem,
LayCheckbox,
LayForm,
LayBreadcrumb,
@ -178,7 +176,6 @@ export {
LayContainer,
LayMenu,
LayMenuItem,
LayMenuChildItem,
LayCheckbox,
LayForm,
LayBreadcrumb,

View File

@ -1,9 +0,0 @@
import type { App } from "vue";
import Component from "./index.vue";
import type { IDefineComponent } from "../type/index";
Component.install = (app: App) => {
app.component(Component.name || "LayMenuChildItem", Component);
};
export default Component as IDefineComponent;

View File

@ -1,25 +0,0 @@
<template>
<dd :class="[selectedKey === id ? 'layui-this' : '']" @click="selectHandle()">
<slot v-if="slots.title" name="title"></slot>
<a v-else href="javascript:void(0)">
{{ title }}
</a>
</dd>
</template>
<script setup name="LayMenuChildItem" lang="ts">
import { defineProps, inject, Ref, useSlots } from "vue";
const slots = useSlots();
const props = defineProps<{
id: string;
title: string;
}>();
const selectedKey: Ref<string> = inject("selectedKey") as Ref<string>;
const selectHandle = function () {
selectedKey.value = props.id;
};
</script>