diff --git a/packages/opendesign/src/_utils/vue-utils.ts b/packages/opendesign/src/_utils/vue-utils.ts index 4a52e24a7b8fc798ab5662b597dc92916e71f0a4..17fbac9c9b3593f8254ea57d4a0fa2d9c216d3aa 100644 --- a/packages/opendesign/src/_utils/vue-utils.ts +++ b/packages/opendesign/src/_utils/vue-utils.ts @@ -223,8 +223,11 @@ export const isEmptySlot = (slot?: Slot) => { if (children.length === 0) { return true; } - // TODO: 如何判断是否为注释节点 - if (children.length === 1 && isTextElement(children[0]) && !children[0].children) { + if (isTextElement(children[0]) && !children[0].children) { + return true; + } + // 如果是注释节点,v-if不渲染的也算注释节点 + if (children[0].type === Symbol.for('v-cmt')) { return true; } return false; diff --git a/packages/opendesign/src/anchor/OAnchorItem.vue b/packages/opendesign/src/anchor/OAnchorItem.vue index 2f5eb44c166d20bbd7548c68d62f16e38db13bf0..d2891d77f50d6d5e4dd4ef8f41318d058eaad87c 100644 --- a/packages/opendesign/src/anchor/OAnchorItem.vue +++ b/packages/opendesign/src/anchor/OAnchorItem.vue @@ -3,6 +3,7 @@ import { computed, inject, nextTick, onMounted, onUnmounted, provide, watch, ref import { OPopover } from '../popover'; import { isCurrentPageLink } from '../_utils/is.ts'; +import { isEmptySlot } from "../_utils/vue-utils.ts"; import { isOverflown } from '../_utils/dom.ts'; import { anchorItemProps } from './types'; import { anchorInjectKey, anchorItemInjectKey } from './provide'; @@ -109,7 +110,7 @@ const handleMouseleave = () => {