tiny-vue/examples/sites/demos/pc/app/dropdown/multi-level-composition-api...

81 lines
1.7 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div>
<p>场景1使用 menu-options 属性定义 children</p>
<tiny-dropdown :menu-options="menuOptions" @item-click="itemClick"></tiny-dropdown>
<p>场景2使用 options 属性定义 children</p>
<tiny-dropdown @item-click="itemClick">
<template #dropdown>
<tiny-dropdown-menu :options="options"> </tiny-dropdown-menu>
</template>
</tiny-dropdown>
</div>
</template>
<script setup>
import { reactive } from 'vue'
import { iconStarDisable } from '@opentiny/vue-icon'
import { Dropdown as TinyDropdown, DropdownMenu as TinyDropdownMenu, Modal } from '@opentiny/vue'
const options = reactive([
{
label: '老友粉1',
icon: iconStarDisable(),
children: [
{
label: '老友粉2.1',
children: [{ label: '狮子头3.1' }]
},
{ label: '老友粉2.2' },
{ label: '老友粉2.3', disabled: true }
]
},
{
label: '狮子头',
disabled: true
},
{
label: '黄金糕',
icon: iconStarDisable()
}
])
const menuOptions = reactive({
options: [
{
label: '老友粉',
icon: iconStarDisable(),
children: [
{
label: '老友粉2.1',
children: [{ label: '狮子头3.1' }]
},
{ label: '老友粉2.2' },
{ label: '老友粉2.3', disabled: true }
]
},
{
label: '狮子头',
divided: true
},
{
label: '黄金糕',
divided: true,
icon: iconStarDisable()
}
]
})
const itemClick = (data) => {
Modal.message({
message: `配置式可以通过 data.itemData 获取配置数据:${JSON.stringify(data.itemData)}`
})
}
</script>
<style lang="less" scoped>
p {
line-height: 1.5;
font-size: 14px;
}
</style>