Skip to content

Commit

Permalink
组件+
Browse files Browse the repository at this point in the history
  • Loading branch information
hyl committed May 13, 2024
1 parent 1c5c4d1 commit f95ff55
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
10 changes: 2 additions & 8 deletions src/components/Dropdown/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<e-tooltip :class="ns('popover')" v-bind="{ ...$props, ...$attrs }" v-model="visible">
<slot />
<template #content>
<e-menu :items="options" direction="vertical" @select="handleSelect" />
<e-menu v-model="selected" :items="options" direction="vertical" @select="handleSelect" />
</template>
</e-tooltip>
</template>
Expand All @@ -22,17 +22,11 @@ withDefaults(
{ options: [] as any, trigger: 'click', placement: 'bottom' }
)
const emits = defineEmits<{
select: [key: string]
}>()
const selected = defineModel('selected', { default: '' })
const visible = defineModel('visible', { default: false })
const handleSelect = (key: string) => {
selected.value = key
emits('select', key as any)
const handleSelect = () => {
// visible.value = false
}
</script>
2 changes: 1 addition & 1 deletion src/components/Menu/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const emits = defineEmits<{
const { namespace } = inject($config, $configInit)!
const active = ref()
const active = defineModel()
const handleItemClick = (key) => {
active.value = key
Expand Down
10 changes: 1 addition & 9 deletions src/components/Tooltip/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const handleOpen = _.debounce(() => {
const updatePosition = async () => {
const { x, y } = await computePosition(referenceSlot.value, floating.value, {
middleware: [shift(), flip(), offset(3)], // 按需引用的中间件
middleware: [shift(), flip(), offset(5)], // 按需引用的中间件
placement: props.placement // 指定初始化浮动位置
})
// console.log(x, y)
Expand Down Expand Up @@ -97,12 +97,4 @@ onMounted(() => {
onUnmounted(() => {
window.removeEventListener(triggerName.value, dismiss)
})
defineExpose({
visible,
referenceSlot,
close: () => {
visible.value = false
}
})
</script>

0 comments on commit f95ff55

Please sign in to comment.