2021-09-29 15:42:53 +00:00
|
|
|
<template>
|
2021-10-12 03:30:07 +00:00
|
|
|
<ul class="layui-nav" :class="[tree ? 'layui-nav-tree' : '']">
|
|
|
|
<slot />
|
|
|
|
</ul>
|
2021-09-29 15:42:53 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup name="LayMenu" lang="ts">
|
2021-10-16 17:18:42 +00:00
|
|
|
import { defineProps, provide, ref, watch } from 'vue'
|
2021-09-29 15:42:53 +00:00
|
|
|
|
2021-10-08 03:09:44 +00:00
|
|
|
const props = withDefaults(
|
2021-10-01 10:20:41 +00:00
|
|
|
defineProps<{
|
2021-10-08 03:09:44 +00:00
|
|
|
selectedKey?: string
|
2021-10-16 17:18:42 +00:00
|
|
|
openKeys?: string[]
|
2021-10-03 14:47:49 +00:00
|
|
|
tree?: boolean
|
2021-10-08 03:09:44 +00:00
|
|
|
}>(),
|
|
|
|
{
|
2021-10-12 03:30:07 +00:00
|
|
|
selectedKey: '',
|
2021-10-16 17:18:42 +00:00
|
|
|
openKeys: function() {
|
|
|
|
return []
|
|
|
|
},
|
2021-10-08 03:09:44 +00:00
|
|
|
tree: false,
|
|
|
|
}
|
|
|
|
)
|
2021-10-06 11:09:03 +00:00
|
|
|
|
|
|
|
const isTree = ref(props.tree)
|
2021-10-16 17:18:42 +00:00
|
|
|
const selectedKey = ref(props.selectedKey)
|
|
|
|
const openKeys = ref([...props.openKeys])
|
2021-10-06 11:09:03 +00:00
|
|
|
|
2021-10-12 03:30:07 +00:00
|
|
|
provide('isTree', isTree)
|
2021-10-16 17:18:42 +00:00
|
|
|
provide('selectedKey', selectedKey)
|
|
|
|
provide('openKeys',openKeys)
|
|
|
|
|
|
|
|
const emit = defineEmits(['update:selectedKey','update:openKeys'])
|
|
|
|
|
|
|
|
watch(selectedKey, function(val) {
|
|
|
|
emit('update:selectedKey',val)
|
|
|
|
})
|
|
|
|
|
|
|
|
watch(openKeys, function(val) {
|
|
|
|
emit('update:openKeys',val)
|
|
|
|
},{deep : true})
|
2021-09-29 15:42:53 +00:00
|
|
|
</script>
|