[新增] menu 菜单组件

This commit is contained in:
就眠仪式
2021-10-05 18:44:07 +08:00
parent cccd93a076
commit 7fc0c0dfd5
7 changed files with 38 additions and 6 deletions

View File

@@ -45,6 +45,7 @@ import LayScroll from './module/scroll/index'
import LayEmpty from './module/empty/index'
import LayFormItem from './module/formItem/index'
import LayRate from './module/rate/index'
import LayDropdown from './module/dropdown/index'
const components: Record<string, IDefineComponent> = {
LayRadio,
@@ -88,7 +89,8 @@ const components: Record<string, IDefineComponent> = {
LaySelectOption,
LayEmpty,
LayFormItem,
LayRate
LayRate,
LayDropdown
}
const install = (app: App, options?: InstallOptions): void => {
@@ -146,6 +148,7 @@ export {
LayEmpty,
LayFormItem,
LayRate,
LayDropdown,
install,
}

View File

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

View File

@@ -0,0 +1,7 @@
<template>
<div>下拉菜单</div>
</template>
<script setup name="LayDropdown" lang="ts">
</script>

View File

@@ -1,10 +1,10 @@
<template>
<li class="layui-nav-item">
<a href="">{{ title }} </a>
<a href="javascript:void(0)">{{ title }} </a>
</li>
<li class="layui-nav-item" v-if="slots.default">
<a href="">
<li class="layui-nav-item" :class="[isOpen?'layui-nav-itemed':'']" v-if="slots.default">
<a href="javascript:void(0)" @click="openHandle">
{{ title }}
<i class="layui-icon layui-icon-down layui-nav-more"></i>
</a>
@@ -15,11 +15,18 @@
</template>
<script setup name="LayMenuItem" lang="ts">
import { defineProps, useSlots } from 'vue'
import { defineProps, ref, useSlots } from 'vue'
const slots = useSlots()
const props =
defineProps<{
title: string
}>()
}>()
const isOpen = ref(false)
const openHandle = function() {
isOpen.value = !isOpen.value
}
</script>