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"
|
2020-06-17 12:45:10 +08:00
|
|
|
:items="menuItems"
|
|
|
|
/>
|
2020-02-07 22:31:26 +08:00
|
|
|
```
|
|
|
|
```js
|
2020-10-22 17:25:26 +08:00
|
|
|
import { h, resolveComponent } from 'vue'
|
2020-10-26 15:03:02 +08:00
|
|
|
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) })
|
|
|
|
}
|
|
|
|
|
2020-06-17 12:45:10 +08:00
|
|
|
const menuItems = [
|
|
|
|
{
|
|
|
|
title: 'Hear the Wind Sing',
|
2020-10-22 17:25:26 +08:00
|
|
|
key: 'hear-the-wind-sing',
|
|
|
|
icon: renderIcon(bookIcon)
|
2020-06-17 12:45:10 +08:00
|
|
|
},
|
|
|
|
{
|
2020-10-22 17:25:26 +08:00
|
|
|
title: 'Pinball 1973',
|
|
|
|
key: 'pinball-1973',
|
|
|
|
icon: renderIcon(bookIcon),
|
2020-06-17 12:45:10 +08:00
|
|
|
disabled: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
title: 'Rat',
|
2020-10-22 17:25:26 +08:00
|
|
|
key: 'rat'
|
2020-06-17 12:45:10 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'A Wild Sheep Chase',
|
2020-10-22 17:25:26 +08:00
|
|
|
key: 'a-wild-sheep-chase',
|
|
|
|
disabled: true,
|
|
|
|
icon: renderIcon(bookIcon)
|
2020-06-17 12:45:10 +08:00
|
|
|
},
|
|
|
|
{
|
2020-10-22 17:25:26 +08:00
|
|
|
title: '舞,舞,舞',
|
|
|
|
key: 'Dance Dance Dance',
|
|
|
|
icon: renderIcon(bookIcon),
|
2020-06-17 12:45:10 +08:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
type: 'group',
|
2020-10-22 17:25:26 +08:00
|
|
|
title: 'People',
|
|
|
|
key: 'people',
|
2020-06-17 12:45:10 +08:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
title: 'Narrator',
|
2020-10-22 17:25:26 +08:00
|
|
|
key: 'narrator',
|
|
|
|
icon: renderIcon(personIcon)
|
2020-06-17 12:45:10 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Sheep Man',
|
2020-10-22 17:25:26 +08:00
|
|
|
key: 'sheep-man',
|
|
|
|
icon: renderIcon(personIcon)
|
2020-06-17 12:45:10 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Beverage',
|
2020-10-22 17:25:26 +08:00
|
|
|
key: 'beverage',
|
|
|
|
icon: renderIcon(wineIcon),
|
2020-06-17 12:45:10 +08:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
title: 'Whisky',
|
2020-10-22 17:25:26 +08:00
|
|
|
key: 'whisky'
|
2020-06-17 12:45:10 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Food',
|
2020-10-22 17:25:26 +08:00
|
|
|
key: 'food',
|
2020-06-17 12:45:10 +08:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
title: 'Sandwich',
|
2020-10-22 17:25:26 +08:00
|
|
|
key: 'sandwich'
|
2020-06-17 12:45:10 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'The past increases. The future recedes.',
|
2020-10-22 17:25:26 +08:00
|
|
|
key: 'the-past-increases-the-future-recedes'
|
2020-06-17 12:45:10 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2020-02-07 22:31:26 +08:00
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
2020-10-22 17:25:26 +08:00
|
|
|
activeKey: null,
|
2020-06-17 12:45:10 +08:00
|
|
|
menuItems
|
2020-02-07 22:31:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|