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

112 lines
2.4 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 属性配置 tiny-dropdown</p>
<tiny-dropdown :menu-options="menuOptions"></tiny-dropdown>
<p>场景2使用 menu-options title 属性配置 tiny-dropdown</p>
<tiny-dropdown :menu-options="menuOptions" title="点击下拉" @item-click="itemClick"></tiny-dropdown>
<p>场景3使用 menu-options text-field 属性配置 tiny-dropdown</p>
<tiny-dropdown :menu-options="menuOptions1" text-field="name"></tiny-dropdown>
<p>场景4使用 options 属性配置 tiny-dropdown-menu</p>
<tiny-dropdown>
<template #dropdown>
<tiny-dropdown-menu :options="options"> </tiny-dropdown-menu>
</template>
</tiny-dropdown>
<p>场景5使用 options text-field 属性配置 tiny-dropdown-menu</p>
<tiny-dropdown>
<template #dropdown>
<tiny-dropdown-menu :options="options1" text-field="name"> </tiny-dropdown-menu>
</template>
</tiny-dropdown>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { iconStarDisable } from '@opentiny/vue-icon'
import { Dropdown as TinyDropdown, DropdownMenu as TinyDropdownMenu, Notify } from '@opentiny/vue'
const options = ref([
{
label: '老友粉',
disabled: true
},
{
label: '狮子头',
divided: true
},
{
label: '黄金糕',
divided: true,
icon: iconStarDisable()
}
])
const options1 = ref([
{
name: '老友粉',
disabled: true
},
{
name: '狮子头',
divided: true
},
{
name: '黄金糕',
divided: true,
icon: iconStarDisable()
}
])
const menuOptions = ref({
options: [
{
label: '老友粉',
disabled: true
},
{
label: '狮子头',
divided: true
},
{
label: '黄金糕',
divided: true,
icon: iconStarDisable()
}
]
})
const menuOptions1 = ref({
options: [
{
name: '老友粉',
disabled: true
},
{
name: '狮子头',
divided: true
},
{
name: '黄金糕',
divided: true,
icon: iconStarDisable()
}
],
textField: 'name'
})
function itemClick(data) {
Notify({
type: 'info',
title: 'itemData',
message: `配置式可以通过data.itemData获取配置数据${JSON.stringify(data.itemData)}`,
position: 'top-right',
duration: 2000
})
}
</script>
<style lang="less" scoped>
p {
line-height: 1.5;
font-size: 14px;
}
</style>