[新增] menu 菜单组件
This commit is contained in:
parent
cccd93a076
commit
7fc0c0dfd5
1
docs/docs/zh-CN/components/dropdown.md
Normal file
1
docs/docs/zh-CN/components/dropdown.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
下拉菜单案例
|
@ -85,6 +85,7 @@ export default {
|
|||||||
{ id: 24, title: '字段',subTitle:"field" ,path: '/zh-CN/components/field' },
|
{ id: 24, title: '字段',subTitle:"field" ,path: '/zh-CN/components/field' },
|
||||||
{ id: 25, title: '空',subTitle:"empty" ,path: '/zh-CN/components/empty' },
|
{ id: 25, title: '空',subTitle:"empty" ,path: '/zh-CN/components/empty' },
|
||||||
{ id: 26, title: '评分',subTitle:"rate" ,path: '/zh-CN/components/rate' },
|
{ id: 26, title: '评分',subTitle:"rate" ,path: '/zh-CN/components/rate' },
|
||||||
|
{ id: 27, title: '下拉', subTitle: "dropdown", path: '/zh-CN/components/dropdown'}
|
||||||
]
|
]
|
||||||
|
|
||||||
const selected = ref(1)
|
const selected = ref(1)
|
||||||
|
@ -136,6 +136,10 @@ const zhCN = [
|
|||||||
path: '/zh-CN/components/rate',
|
path: '/zh-CN/components/rate',
|
||||||
component: () => import('../../docs/zh-CN/components/rate.md'),
|
component: () => import('../../docs/zh-CN/components/rate.md'),
|
||||||
meta: { title: '评分' },
|
meta: { title: '评分' },
|
||||||
|
},{
|
||||||
|
path: '/zh-CN/components/dropdown',
|
||||||
|
component: () => import('../../docs/zh-CN/components/dropdown.md'),
|
||||||
|
meta: { title: '下拉' },
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -45,6 +45,7 @@ import LayScroll from './module/scroll/index'
|
|||||||
import LayEmpty from './module/empty/index'
|
import LayEmpty from './module/empty/index'
|
||||||
import LayFormItem from './module/formItem/index'
|
import LayFormItem from './module/formItem/index'
|
||||||
import LayRate from './module/rate/index'
|
import LayRate from './module/rate/index'
|
||||||
|
import LayDropdown from './module/dropdown/index'
|
||||||
|
|
||||||
const components: Record<string, IDefineComponent> = {
|
const components: Record<string, IDefineComponent> = {
|
||||||
LayRadio,
|
LayRadio,
|
||||||
@ -88,7 +89,8 @@ const components: Record<string, IDefineComponent> = {
|
|||||||
LaySelectOption,
|
LaySelectOption,
|
||||||
LayEmpty,
|
LayEmpty,
|
||||||
LayFormItem,
|
LayFormItem,
|
||||||
LayRate
|
LayRate,
|
||||||
|
LayDropdown
|
||||||
}
|
}
|
||||||
|
|
||||||
const install = (app: App, options?: InstallOptions): void => {
|
const install = (app: App, options?: InstallOptions): void => {
|
||||||
@ -146,6 +148,7 @@ export {
|
|||||||
LayEmpty,
|
LayEmpty,
|
||||||
LayFormItem,
|
LayFormItem,
|
||||||
LayRate,
|
LayRate,
|
||||||
|
LayDropdown,
|
||||||
install,
|
install,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
src/module/dropdown/index.ts
Normal file
9
src/module/dropdown/index.ts
Normal 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
|
7
src/module/dropdown/index.vue
Normal file
7
src/module/dropdown/index.vue
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<div>下拉菜单</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="LayDropdown" lang="ts">
|
||||||
|
|
||||||
|
</script>
|
@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<li class="layui-nav-item">
|
<li class="layui-nav-item">
|
||||||
<a href="">{{ title }} </a>
|
<a href="javascript:void(0)">{{ title }} </a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="layui-nav-item" v-if="slots.default">
|
<li class="layui-nav-item" :class="[isOpen?'layui-nav-itemed':'']" v-if="slots.default">
|
||||||
<a href="">
|
<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>
|
||||||
@ -15,11 +15,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="LayMenuItem" lang="ts">
|
<script setup name="LayMenuItem" lang="ts">
|
||||||
import { defineProps, useSlots } from 'vue'
|
import { defineProps, ref, useSlots } from 'vue'
|
||||||
const slots = useSlots()
|
const slots = useSlots()
|
||||||
|
|
||||||
const props =
|
const props =
|
||||||
defineProps<{
|
defineProps<{
|
||||||
title: string
|
title: string
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const isOpen = ref(false)
|
||||||
|
|
||||||
|
const openHandle = function() {
|
||||||
|
isOpen.value = !isOpen.value
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user