2019-12-14 02:05:31 +08:00
|
|
|
# 多级
|
2020-02-04 22:07:55 +08:00
|
|
|
下拉菜单可以是多级的。
|
2019-12-14 02:05:31 +08:00
|
|
|
```html
|
|
|
|
<n-dropdown
|
2020-02-04 22:07:55 +08:00
|
|
|
:options="options"
|
2019-12-14 02:05:31 +08:00
|
|
|
placement="bottom-start"
|
|
|
|
trigger="click"
|
2020-02-04 22:07:55 +08:00
|
|
|
:default-focus="false"
|
2019-12-14 02:05:31 +08:00
|
|
|
@select="handleSelect"
|
|
|
|
>
|
2020-02-04 22:07:55 +08:00
|
|
|
<n-button>人物和食物</n-button>
|
2019-12-14 02:05:31 +08:00
|
|
|
</n-dropdown>
|
|
|
|
```
|
2020-02-04 22:07:55 +08:00
|
|
|
|
2019-12-14 02:05:31 +08:00
|
|
|
```js
|
2020-02-04 22:07:55 +08:00
|
|
|
const options = [
|
|
|
|
{
|
|
|
|
label: '杰·盖茨比',
|
|
|
|
key: 'jay gatsby'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '黛西·布坎南',
|
|
|
|
key: 'daisy buchanan'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '尼克·卡拉威',
|
|
|
|
key: 'nick carraway'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'submenu',
|
|
|
|
label: '其他',
|
|
|
|
key: 'others',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: '乔丹·贝克',
|
|
|
|
key: 'jordan baker'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '汤姆·布坎南',
|
|
|
|
key: 'tom buchanan'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'submenu',
|
|
|
|
label: '其他',
|
|
|
|
key: 'others',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: '鸡肉',
|
|
|
|
key: 'chicken'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '牛肉',
|
|
|
|
key: 'beef'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2019-12-14 02:05:31 +08:00
|
|
|
export default {
|
2020-02-04 22:07:55 +08:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
options
|
|
|
|
}
|
|
|
|
},
|
2019-12-14 02:05:31 +08:00
|
|
|
methods: {
|
|
|
|
handleSelect (name) {
|
|
|
|
this.$NMessage.info(name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-04 22:07:55 +08:00
|
|
|
```
|