fix : 修复tooltip细节
This commit is contained in:
40
src/components/Tooltip.vue
Normal file
40
src/components/Tooltip.vue
Normal 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>
|
||||
Reference in New Issue
Block a user