layui/example/docs/zh-CN/components/menu.md

294 lines
6.2 KiB
Markdown
Raw Normal View History

::: anchor
:::
2022-02-05 21:20:07 +00:00
::: title 基本介绍
:::
::: describe 导航菜单是一个网站的灵魂,用户依赖导航在各个页面中进行跳转。
:::
2021-10-25 17:13:23 +00:00
::: title 基础使用
2021-10-19 14:28:44 +00:00
:::
2021-09-29 15:42:53 +00:00
::: demo
<template>
2022-01-29 16:13:52 +00:00
<lay-menu v-model:selectedKey="selectedKey" v-model:openKeys="openKeys">
2021-10-08 03:09:44 +00:00
<lay-menu-item title="首页" id="1"></lay-menu-item>
<lay-menu-item title="用户" id="2"></lay-menu-item>
<lay-menu-item title="角色" id="3"></lay-menu-item>
<lay-sub-menu title="目录" id="7">
2022-01-30 13:50:38 +00:00
<lay-menu-item title="菜单" id="8"></lay-menu-item>
<lay-menu-item title="菜单" id="9"></lay-menu-item>
<lay-sub-menu title="菜单" id="10">
<lay-menu-item title="菜单" id="11"></lay-menu-item>
<lay-menu-item title="菜单" id="12"></lay-menu-item>
<lay-menu-item title="菜单" id="13"></lay-menu-item>
</lay-sub-menu>
</lay-sub-menu>
2021-09-29 15:42:53 +00:00
</lay-menu>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const selectedKey = ref("5")
const openKeys = ref(["7"])
2021-09-29 15:42:53 +00:00
return {
selectedKey,
openKeys
2021-09-29 15:42:53 +00:00
}
}
}
</script>
:::
2021-10-01 10:20:41 +00:00
2021-10-25 17:13:23 +00:00
::: title 垂直导航
2021-10-19 14:28:44 +00:00
:::
2021-10-01 10:20:41 +00:00
::: demo
<template>
2022-01-09 14:11:28 +00:00
<lay-menu v-model:selectedKey="selectedKey" v-model:openKeys="openKeys" :tree="true">
<lay-menu-item title="首页" id="1"></lay-menu-item>
2021-10-08 03:09:44 +00:00
<lay-menu-item title="用户" id="2"></lay-menu-item>
<lay-menu-item title="角色" id="3"></lay-menu-item>
<lay-sub-menu title="目录" id="7">
2022-01-30 13:50:38 +00:00
<lay-menu-item title="菜单" id="8"></lay-menu-item>
<lay-menu-item title="菜单" id="9"></lay-menu-item>
<lay-sub-menu title="菜单" id="10">
<lay-menu-item title="菜单" id="11"></lay-menu-item>
<lay-menu-item title="菜单" id="12"></lay-menu-item>
<lay-menu-item title="菜单" id="13"></lay-menu-item>
</lay-sub-menu>
</lay-sub-menu>
</lay-menu>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const openKeys = ref(["7"])
2022-01-09 14:11:28 +00:00
const selectedKey = ref("5")
return {
openKeys,
selectedKey
}
}
}
</script>
:::
2022-01-30 12:29:16 +00:00
::: title 反转样式
:::
::: demo
<template>
2022-01-30 13:50:38 +00:00
<lay-menu level="true" v-model:selectedKey="selectedKey" inverted="true" v-model:openKeys="openKeys" :tree="true">
2022-01-30 12:29:16 +00:00
<lay-menu-item title="首页" id="1"></lay-menu-item>
<lay-menu-item title="用户" id="2"></lay-menu-item>
<lay-menu-item title="角色" id="3"></lay-menu-item>
<lay-sub-menu title="目录" id="7">
2022-01-30 13:50:38 +00:00
<lay-menu-item title="菜单" id="8"></lay-menu-item>
<lay-menu-item title="菜单" id="9"></lay-menu-item>
<lay-sub-menu title="菜单" id="10">
<lay-menu-item title="菜单" id="11"></lay-menu-item>
<lay-menu-item title="菜单" id="12"></lay-menu-item>
<lay-menu-item title="菜单" id="13"></lay-menu-item>
2022-01-30 12:29:16 +00:00
</lay-sub-menu>
</lay-sub-menu>
</lay-menu>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const openKeys = ref(["7"])
const selectedKey = ref("5")
return {
openKeys,
selectedKey
}
}
}
</script>
:::
::: title 切换主题
:::
::: demo
<template>
<lay-menu v-model:selectedKey="selectedKey" theme="light" v-model:openKeys="openKeys" :tree="true">
<lay-menu-item title="首页" id="1"></lay-menu-item>
<lay-menu-item title="用户" id="2"></lay-menu-item>
<lay-menu-item title="角色" id="3"></lay-menu-item>
<lay-sub-menu title="目录" id="7">
2022-01-30 13:50:38 +00:00
<lay-menu-item title="菜单" id="8"></lay-menu-item>
<lay-menu-item title="菜单" id="9"></lay-menu-item>
<lay-sub-menu title="菜单" id="10">
<lay-menu-item title="菜单" id="11"></lay-menu-item>
<lay-menu-item title="菜单" id="12"></lay-menu-item>
<lay-menu-item title="菜单" id="13"></lay-menu-item>
</lay-sub-menu>
</lay-sub-menu>
</lay-menu>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const openKeys = ref(["7"])
const selectedKey = ref("5")
return {
openKeys,
selectedKey
}
}
}
</script>
:::
::: title 菜单插槽
:::
::: demo
<template>
<lay-menu v-model:selectedKey="selectedKey" v-model:openKeys="openKeys" v-model:tree="isTree">
<lay-menu-item id="1">
2022-02-01 19:27:34 +00:00
<router-link to="">
<lay-icon type="layui-icon-home"></lay-icon>
首页
</router-link>
</lay-menu-item>
2022-01-09 14:11:28 +00:00
<lay-sub-menu id="7">
<template v-slot:title>
2022-02-01 19:27:34 +00:00
<router-link to="">
<lay-icon type="layui-icon-home"></lay-icon>
目录
</router-link>
</template>
<lay-menu-item id="8">
2022-02-01 19:27:34 +00:00
<router-link to="">
<lay-icon type="layui-icon-home"></lay-icon>
菜单
</router-link>
</lay-menu-item>
<lay-menu-item id="9">
2022-02-01 19:27:34 +00:00
<router-link to="">
<lay-icon type="layui-icon-home"></lay-icon>
菜单
</router-link>
</lay-menu-item>
2022-01-09 14:11:28 +00:00
</lay-sub-menu>
2021-10-01 10:20:41 +00:00
</lay-menu>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
2021-10-15 06:57:48 +00:00
const isTree = ref(true)
const selectedKey = ref("5")
const openKeys = ref(["7"])
2021-10-15 06:57:48 +00:00
2021-10-01 10:20:41 +00:00
return {
isTree,
openKeys,
selectedKey
2021-10-01 10:20:41 +00:00
}
}
}
</script>
:::
2021-10-09 02:41:52 +00:00
2022-01-09 14:11:28 +00:00
::: title Menu 属性
2021-10-13 02:04:43 +00:00
:::
2021-10-12 10:00:09 +00:00
2021-11-07 07:55:08 +00:00
::: table
2021-11-07 07:56:24 +00:00
| 属性 | 描述 | 备注 |
| ------------------- | ------ | ---- |
| v-model:selectedKey | 选中项 | -- |
| v-model:openKeys | 打开项 | -- |
2022-01-29 16:13:52 +00:00
| theme | 菜单主题 | `dark` `light` |
2022-01-30 12:29:16 +00:00
| inverted | 特殊的激活样式 | `true` `false` |
2022-01-30 13:50:38 +00:00
| level | 菜单层级 | `true` `false` |
2021-11-07 07:55:08 +00:00
:::
2021-10-15 01:30:37 +00:00
2022-01-09 14:11:28 +00:00
::: title Menu Item 属性
:::
::: table
| 插槽 | 描述 | 备注 |
| ----- | -------- | ---- |
| title | 菜单标题 | -- |
:::
::: title Menu Item 插槽
:::
::: table
| 插槽 | 描述 | 备注 |
| ----- | -------- | ---- |
| title | 菜单标题 | -- |
:::
::: title Sub Menu 属性
:::
::: table
| 插槽 | 描述 | 备注 |
| ----- | -------- | ---- |
| title | 菜单标题 | -- |
:::
::: title Sub Menu 插槽
2021-10-15 01:30:37 +00:00
:::
2021-11-07 07:55:08 +00:00
::: table
| 插槽 | 描述 | 备注 |
| ----- | -------- | ---- |
| title | 菜单标题 | -- |
2021-11-07 07:55:08 +00:00
2021-11-07 07:56:24 +00:00
:::
2021-12-16 09:57:59 +00:00
::: comment
2022-01-12 06:19:06 +00:00
:::
::: previousNext nav
2022-01-30 12:37:33 +00:00
:::