代码,解决方法
<el-tooltip
:content="childItem.iconPageName"
placement="bottom"
effect="light"
:disabled="!isShowTooltip"
>
<p class="text-hidden" @mouseenter="visibilityChange($event)">
{{ childItem.iconPageName }}
</p>
</el-tooltip>
// 文本溢出隐藏
visibilityChange(event) {
const ev = event.target;
const ev_weight = ev.scrollWidth; // 文本的实际宽度
const content_weight = ev.clientWidth; // 文本的可视宽度
if (ev_weight > content_weight) {
// 实际宽度 > 可视宽度 文字溢出
this.isShowTooltip = true;
} else {
// 否则为不溢出
this.isShowTooltip = false;
}
}