fix : 修复tooltip细节

This commit is contained in:
2024-05-18 23:04:51 +08:00
parent b7ebd66729
commit c675b1ec48
2 changed files with 43 additions and 11 deletions

View File

@@ -0,0 +1,40 @@
<template>
<el-tooltip
effect="dark"
:content="props.content"
placement="bottom-start"
:disabled="isShow"
>
<div class="content" :style="{width: props.width+'px'}" @mouseover="isShowTooltip">
<span ref="contentRef">
<slot name="content">{{ props.content }}</slot>
</span>
</div>
</el-tooltip>
</template>
<script setup>
const props = defineProps({
content: {
type: String,
default: ''
}, width: {
type: String,
default: ''
}
})
const contentRef = ref()
const isShow = ref(false)
const isShowTooltip = () => {
isShow.value = props.width > contentRef.value.offsetWidth;
}
</script>
<style>
.content {
width: 45px;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
padding-top: 3px;
}
</style>