naive-ui/demo/documentation/components/menu/enUS/indent.demo.md

104 lines
2.1 KiB
Markdown
Raw Normal View History

2020-02-07 22:31:26 +08:00
# Indent
You can specify `indent` & `root-indent` of the menu. `root-indent` only determines the first-leveled children.
```html
<n-menu
2020-10-22 17:25:26 +08:00
v-model:value="activeKey"
2020-02-07 22:31:26 +08:00
:root-indent="36"
:indent="12"
:items="menuItems"
/>
2020-02-07 22:31:26 +08:00
```
```js
2020-10-22 17:25:26 +08:00
import { h, resolveComponent } from 'vue'
import bookIcon from 'naive-ui/lib/icons/book-outline.vue'
import personIcon from 'naive-ui/lib/icons/person-outline.vue'
import wineIcon from 'naive-ui/lib/icons/wine-outline.vue'
2020-02-07 22:31:26 +08:00
2020-10-22 17:25:26 +08:00
function renderIcon(icon) {
return () => h(resolveComponent('n-icon'), null, { default: () => h(icon) })
}
const menuItems = [
{
title: 'Hear the Wind Sing',
2020-10-22 17:25:26 +08:00
key: 'hear-the-wind-sing',
icon: renderIcon(bookIcon)
},
{
2020-10-22 17:25:26 +08:00
title: 'Pinball 1973',
key: 'pinball-1973',
icon: renderIcon(bookIcon),
disabled: true,
children: [
{
title: 'Rat',
2020-10-22 17:25:26 +08:00
key: 'rat'
}
]
},
{
title: 'A Wild Sheep Chase',
2020-10-22 17:25:26 +08:00
key: 'a-wild-sheep-chase',
disabled: true,
icon: renderIcon(bookIcon)
},
{
2020-10-22 17:25:26 +08:00
title: '舞,舞,舞',
key: 'Dance Dance Dance',
icon: renderIcon(bookIcon),
children: [
{
type: 'group',
2020-10-22 17:25:26 +08:00
title: 'People',
key: 'people',
children: [
{
title: 'Narrator',
2020-10-22 17:25:26 +08:00
key: 'narrator',
icon: renderIcon(personIcon)
},
{
title: 'Sheep Man',
2020-10-22 17:25:26 +08:00
key: 'sheep-man',
icon: renderIcon(personIcon)
}
]
},
{
title: 'Beverage',
2020-10-22 17:25:26 +08:00
key: 'beverage',
icon: renderIcon(wineIcon),
children: [
{
title: 'Whisky',
2020-10-22 17:25:26 +08:00
key: 'whisky'
}
]
},
{
title: 'Food',
2020-10-22 17:25:26 +08:00
key: 'food',
children: [
{
title: 'Sandwich',
2020-10-22 17:25:26 +08:00
key: 'sandwich'
}
]
},
{
title: 'The past increases. The future recedes.',
2020-10-22 17:25:26 +08:00
key: 'the-past-increases-the-future-recedes'
}
]
}
]
2020-02-07 22:31:26 +08:00
export default {
data () {
return {
2020-10-22 17:25:26 +08:00
activeKey: null,
menuItems
2020-02-07 22:31:26 +08:00
}
}
}
```