60 lines
1.2 KiB
Vue
Raw Normal View History

2022-02-01 07:23:20 +08:00
<script lang="ts">
export default {
name: "LayMenu"
}
</script>
2021-09-29 23:42:53 +08:00
2022-02-01 07:23:20 +08:00
<script setup lang="ts">
2021-12-09 14:11:29 +08:00
import { computed, defineProps, provide } from "vue";
2022-01-28 11:43:48 +08:00
import "./index.less";
export interface LayMenuProps {
selectedKey?: string;
openKeys?: string[];
tree?: boolean;
theme?: string;
2022-01-30 20:29:16 +08:00
inverted?: boolean;
2022-01-30 21:50:38 +08:00
level?: boolean;
}
const emit = defineEmits(["update:selectedKey", "update:openKeys"]);
const props = withDefaults(defineProps<LayMenuProps>(), {
selectedKey: "",
openKeys: () => [],
tree: false,
2022-01-30 20:29:16 +08:00
theme: 'dark',
2022-01-30 21:50:38 +08:00
inverted: false,
level: false
});
const isTree = computed(() => props.tree);
2021-10-06 19:09:03 +08:00
const openKeys = computed({
get() {
return props.openKeys;
},
set(val) {
emit("update:selectedKey", val);
},
});
const selectedKey = computed({
get() {
return props.selectedKey;
},
set(val) {
emit("update:selectedKey", val);
},
});
provide("isTree", isTree);
provide("selectedKey", selectedKey);
provide("openKeys", openKeys);
2021-09-29 23:42:53 +08:00
</script>
2022-02-01 07:23:20 +08:00
<template>
<ul class="layui-nav" :class="[level? 'level':'',inverted ? 'inverted':'',tree ? 'layui-nav-tree' : '', theme === 'dark' ? 'layui-nav-dark':'layui-nav-light' ]">
<slot></slot>
</ul>
</template>