当前位置: 首页 > news >正文

【无标题】文本超过一行隐藏,鼠标经过显示提示框

创建一个组件专门用来出来文字的

<template><div class="tooltip-wrap"><el-tooltipref="tlp":content="text"effect="dark":disabled="!tooltipFlag":placement="placement"popper-class="tooltip-width"><p:class="className"@mouseenter.stop="visibilityChange($event)">{{ text ? text : '-' }}</p></el-tooltip></div>
</template><script>
export default {name: 'NormalTextTooltipol',props: {text: { type: String, default: '' }, // 字符内容placement: { type: String, default: 'top-start' }, // 文字出现的位置className: { type: String, default: 'text' } // class名},data() {return {// 控制提示框是否可用tooltipFlag: false}},methods: {// tooltip的可控visibilityChange(event) {const ev = event.targetconst ev_weight = ev.scrollWidth // 文本的实际宽度const content_weight = this.$refs.tlp.$el.parentNode.clientWidth // 文本容器宽度(父节点)if (ev_weight > content_weight) {// 文本宽度 > 实际内容宽度  =》内容溢出this.tooltipFlag = true} else {// 否则为不溢出this.tooltipFlag = false}}}
}
</script><style scoped>.tooltip-wrap {z-index: 999;}.title {font-size: 16px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;width: 350px;}.subtask-title {overflow: hidden;white-space: nowrap;text-overflow: ellipsis;font-size: 14px;color: #262626;cursor: pointer;}p {width: 100%;margin: 0;}</style>

在使用的地方引入就可以了

<normal-text-tooltipol ref="normalTextTooltipol" :text="item.taskTitle" :class-name="'title'" />

在这里插入图片描述

效果

在这里插入图片描述

http://www.lryc.cn/news/241052.html

相关文章:

  • 成为独立开发者有多难
  • C++ 正则表达式使用
  • VSCode任务tasks.json中的问题匹配器problemMatcher的问题匹配模式ProblemPattern详解
  • CSS 实现文本框签名
  • Spring 定时任务如何到达某一指定时间点后,触发任务机制
  • PDF Reader Pro 3.0.1.0(pdf阅读器)
  • 【rust:tauri-app踩坑记录】dangerousRemoteDomainIpcAccess 不适用于IP地址,临时解决方案
  • [Docker]八.Docker 容器跨主机通讯
  • 面试cast:reinterpret_cast/const_cast/static_cast/dynamic_cast
  • 致远M3 反序列化RCE漏洞复现(XVE-2023-24878)
  • Ubuntu安装CUDA驱动
  • 【MySQL】内连接和外连接
  • U盘启动制作工具Rufus
  • Ubuntu 22.04安装vscode
  • 计算机视觉的应用19-基于pytorch框架搭建卷积神经网络CNN的卫星地图分类问题实战应用
  • Java 获取本地ip网卡信息
  • 将kali系统放在U盘中插入电脑直接进入kali系统
  • 二十四、RestClient操作文档
  • 【Docker】从零开始:9.Docker命令:Push推送仓库(Docker Hub,阿里云)
  • Centos部署GitLab-备份恢复
  • CSV用EXCEL打开后为科学计数法(后几位丢失)解决方法
  • flink sqlClient提交hiveIceberg
  • SpringBoot 导入其他配置文件
  • 景区智慧旅游智能化系统方案:PPT全文58页,附下载
  • Java特殊文件读取案例Properties
  • 搜维尔科技:Faceware面部捕捉最佳实践!
  • 如何使用ArcGIS Pro进行坐标转换
  • Python----类对象和实例对象
  • [23] 4K4D: Real-Time 4D View Synthesis at 4K Resolution
  • MySQL错误之ONLY_FULL_GROUP_BY