🕛 [修复] menu 组件目录展开
This commit is contained in:
parent
567cd9b783
commit
ed2b2b398e
@ -5,10 +5,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="LayMenu" lang="ts">
|
<script setup name="LayMenu" lang="ts">
|
||||||
import { defineProps } from 'vue'
|
import { defineProps, provide, ref } from 'vue'
|
||||||
|
|
||||||
const props =
|
const props =
|
||||||
defineProps<{
|
defineProps<{
|
||||||
tree?: boolean
|
tree?: boolean
|
||||||
|
selectedKeys?: string[]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const isTree = ref(props.tree)
|
||||||
|
const selectKeys = ref(props.selectedKeys)
|
||||||
|
|
||||||
|
provide("isTree",isTree);
|
||||||
|
provide("selectKeys",selectKeys)
|
||||||
</script>
|
</script>
|
||||||
|
@ -3,30 +3,43 @@
|
|||||||
<a href="javascript:void(0)">{{ title }} </a>
|
<a href="javascript:void(0)">{{ title }} </a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="layui-nav-item" :class="[isOpen?'layui-nav-itemed':'']" v-if="slots.default">
|
<li
|
||||||
|
class="layui-nav-item"
|
||||||
|
:class="[isOpen && isTree ? 'layui-nav-itemed' : '']"
|
||||||
|
v-if="slots.default"
|
||||||
|
>
|
||||||
<a href="javascript:void(0)" @click="openHandle">
|
<a href="javascript:void(0)" @click="openHandle">
|
||||||
{{ title }}
|
{{ title }}
|
||||||
<i class="layui-icon layui-icon-down layui-nav-more"></i>
|
<i class="layui-icon layui-icon-down layui-nav-more"></i>
|
||||||
</a>
|
</a>
|
||||||
<dl class="layui-nav-child">
|
<dl
|
||||||
|
class="layui-nav-child"
|
||||||
|
:class="[
|
||||||
|
isOpen && !isTree ? 'layui-show' : '',
|
||||||
|
!isTree ? 'layui-anim layui-anim-upbit' : '',
|
||||||
|
]"
|
||||||
|
>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="LayMenuItem" lang="ts">
|
<script setup name="LayMenuItem" lang="ts">
|
||||||
import { defineProps, ref, useSlots } from 'vue'
|
import { defineProps, inject, ref, useSlots } from 'vue'
|
||||||
const slots = useSlots()
|
const slots = useSlots()
|
||||||
|
|
||||||
const props =
|
const props =
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
key: string
|
||||||
title: string
|
title: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const isOpen = ref(false)
|
const isOpen = ref(false)
|
||||||
|
|
||||||
const openHandle = function() {
|
const isTree = inject('isTree')
|
||||||
|
const selectKeys = inject('selectKeys')
|
||||||
|
|
||||||
|
const openHandle = function () {
|
||||||
isOpen.value = !isOpen.value
|
isOpen.value = !isOpen.value
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -3,7 +3,5 @@
|
|||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="LayPanel" lang="ts">
|
<script setup name="LayPanel" lang="ts">
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user