Skip to content

Commit

Permalink
chore(@vben/web-antd): optimize the getPosition function
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjue666 committed Aug 7, 2024
1 parent 301b709 commit 11b3460
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions apps/web-antd/src/components/EllipsisText/tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ const left = ref(0); // 提示框left定位
const contentRef = ref(); // 声明一个同名的模板引用
const tooltipRef = ref(); // 声明一个同名的模板引用
function getPosition() {
const contentWidth = contentRef.value && contentRef.value.offsetWidth; // 展示文本宽度
const tooltipWidth = tooltipRef.value && tooltipRef.value.offsetWidth; // 提示文本宽度
const tooltipHeight = tooltipRef.value && tooltipRef.value.offsetHeight; // 提示文本高度
const contentWidth = contentRef.value?.offsetWidth || 0; // 展示文本宽度
const tooltipWidth = tooltipRef.value?.offsetWidth || 0; // 提示文本宽度
const tooltipHeight = tooltipRef.value?.offsetHeight || 0; // 提示文本高度
top.value = tooltipHeight + 4;
left.value = (tooltipWidth - contentWidth) / 2;
}
Expand Down

0 comments on commit 11b3460

Please sign in to comment.