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

阿里云 做购物网站网站外链群发软件

阿里云 做购物网站网站,外链群发软件,做网站导航条怎么弄,网站维护提示页面模板eltable 合计行添加tooltip 问题描述: eltable 合计行单元格内容过长会换行,需求要求合计行数据超长显示 … ,鼠标 hover 时显示提示信息。 解决方案:eltable合计行没有对外的修改接口,想法是 自己实现一个tooltip&a…

eltable 合计行添加tooltip

  • 问题描述:
    eltable 合计行单元格内容过长会换行,需求要求合计行数据超长显示 … ,鼠标 hover 时显示提示信息。
    在这里插入图片描述

  • 解决方案:eltable合计行没有对外的修改接口,想法是 自己实现一个tooltip, 为合计行单元添加鼠标移入移出事件,移入显示tooltip,移出隐藏tooltip,tooltip的定位和内容通过移入时拿到单元格位置和内容。

  • 实现代码 (最后有优化代码)

<template><div class="content"><el-table show-summary :data="data"><el-table-columnv-for="item in header"v-bind="item":show-overflow-tooltip="true"></el-table-column></el-table><!-- 自定义tooltip --><Transition name="el-fade-in"><div v-show="toolTipVisble" id="customTooltip" ref="customTooltip">{{ tipMsg }}<div class="popper__arrow"></div></div></Transition></div>
</template>
<script>
export default {components: {},data() {return {//合计行提示toolTipVisble: false,tipMsg: "",header: [{ label: "列1", prop: "col1", width: "70px" },{ label: "列2", prop: "col2", width: "70px" },{ label: "列3", prop: "col3", width: "70px" },{ label: "列4", prop: "col4", minWidth: "70px" },],data: [{col1: "23333333333333",col2: "2345679",col3: "66666666666666",col4: "4",},{ col1: "2", col2: "2", col3: "3", col4: "4" },{ col1: "2", col2: "2", col3: "3", col4: "4" },{ col1: "2", col2: "2", col3: "3", col4: "4" },{ col1: "2", col2: "2", col3: "3", col4: "4" },],};},mounted() {this.setSummaryListener();},methods: {setSummaryListener() {let that = this;let table = document.querySelector(".el-table__footer-wrapper>table");this.$nextTick(() => {for (let rowIndex = 0; rowIndex < table.rows.length; rowIndex++) {let row = table.rows[rowIndex].cells;for (let colIndex = 0; colIndex < row.length; colIndex++) {let col = row[colIndex];let cells = col.getElementsByClassName("cell");if (cells && cells.length > 0) {let cell = cells[0];if (cell.scrollWidth > cell.offsetWidth) {cell.onmouseenter = function () {that.setTooltip(true, rowIndex, colIndex, cell);};cell.onmouseleave = function () {that.setTooltip(false, rowIndex, colIndex, cell);};}}}}});},setTooltip(isShow, rowIndex, columnIndex, colEl) {this.toolTipVisble = isShow;if (isShow) {this.tipMsg = colEl.innerText || colEl.textContent;let toolTip = this.$refs.customTooltip;let rect = colEl.getBoundingClientRect();//向上偏移量const offsetTop = 50;toolTip.style.top = rect.top - offsetTop + "px";this.$nextTick(() => {const cellBorderWidth = 1;toolTip.style.left =rect.left -(toolTip.offsetWidth / 2 -(colEl.offsetWidth + cellBorderWidth * 2) / 2) +"px";});}},},
};
</script>
<style>
/* 合计行单元格样式 */
.el-table__footer-wrapper .el-table__footer .el-table__cell .cell {overflow: hidden;text-overflow: ellipsis;word-break: break-all;white-space: nowrap;
}
</style><style lang="scss" scoped>
#customTooltip {position: absolute;transform-origin: center bottom;background: #303133;color: #fff;border-radius: 4px;padding: 10px;font-size: 12px;line-height: 1.2;word-wrap: break-word;.popper__arrow {position: absolute;display: block;width: 0px;height: 0px;bottom: -12px;left: 42%;border-left: 6px solid transparent;border-right: 6px solid transparent;border-bottom: 6px solid transparent;border-top: 6px solid #303133;}
}
.content {display: flex;flex-direction: column;width: 100%;height: 500px;
}
</style>
  • 实现效果
    在这里插入图片描述
  • 瞅瞅源码
    eltable 数据行单元格提示信息show-overflow-tooltip源码实现思路跟上面差不多。
    单元格的提示信息也是绑定鼠标移入移出事件,提示信息用的el-tooltip。
    el-tooltip:这里el-tooltip标签里面没有内容,之后通过鼠标移入事件绑定。
    在这里插入图片描述
    单元格绑定鼠标事件
    在这里插入图片描述
    referenceElm 绑定目标对象(提示信息定位对象)。
    在这里插入图片描述
  • 优化一下我自己写的tooltip,用el-tooltip实现。
<template><div class="content"><el-table show-summary :data="data"><el-table-columnv-for="item in header"v-bind="item":show-overflow-tooltip="true"></el-table-column></el-table><!-- 自定义tooltip --><!-- <Transition name="el-fade-in"><div v-show="toolTipVisble" id="customTooltip" ref="customTooltip">{{ tipMsg }}<div class="popper__arrow"></div></div></Transition> --><el-tooltipplacement="top"ref="tooltip":content="tooltipContent"></el-tooltip></div>
</template><script>
export default {components: {},data() {return {tooltipContent: "",header: [{ label: "列1", prop: "col1", width: "70px" },{ label: "列2", prop: "col2", width: "70px" },{ label: "列3", prop: "col3", width: "70px" },{ label: "列4", prop: "col4", minWidth: "500px" },],data: [{col1: "23333333333333",col2: "2345679",col3: "66666666666666",col4: "4",},{ col1: "2", col2: "2", col3: "3", col4: "4" },{ col1: "2", col2: "2", col3: "3", col4: "4" },{ col1: "2", col2: "2", col3: "3", col4: "4" },{ col1: "2", col2: "2", col3: "3", col4: "4" },],};},mounted() {this.setSummaryListener();},methods: {setSummaryListener() {let that = this;let table = document.querySelector(".el-table__footer-wrapper>table");this.$nextTick(() => {for (let rowIndex = 0; rowIndex < table.rows.length; rowIndex++) {let row = table.rows[rowIndex].cells;for (let colIndex = 0; colIndex < row.length; colIndex++) {let col = row[colIndex];let cells = col.getElementsByClassName("cell");if (cells && cells.length > 0) {let cell = cells[0];if (cell.scrollWidth > cell.offsetWidth) {cell.onmouseenter = function () {that.setTooltip(true, rowIndex, colIndex, cell);};cell.onmouseleave = function () {that.setTooltip(false, rowIndex, colIndex, cell);};}}}}});},setTooltip(isShow, rowIndex, columnIndex, colEl) {const tooltip = this.$refs.tooltip;if (isShow) {this.tooltipContent = colEl.innerText || colEl.textContent;tooltip.referenceElm = colEl;tooltip.$refs.popper && (tooltip.$refs.popper.style.display = "none");tooltip.doDestroy();tooltip.setExpectedState(true);tooltip.handleShowPopper();} else {tooltip.setExpectedState(false);tooltip.handleClosePopper();}},},
};
</script><style>
/* 合计行单元格样式 */
.el-table__footer-wrapper .el-table__footer .el-table__cell .cell {overflow: hidden;text-overflow: ellipsis;word-break: break-all;white-space: nowrap;
}
</style><style lang="scss" scoped>
.content { width: 100%;height: 500px;
}
</style>
http://www.yidumall.com/news/56970.html

相关文章:

  • 做最漂亮的网站怎样申请网站
  • 如何上国外购物网站seo关键词怎么选择
  • 郑州企业网站排名优化佛山网站建设技术托管
  • 网站安装不了wordpress青岛seo百科
  • 做编程网站有哪些内容百度seo一本通
  • 延安网站设计公司如何制作一个自己的网页网站
  • ui设计师创意平台标题优化怎样选关键词
  • 使用bootstrap做网站的视频交换链接营销成功案例
  • 哈尔滨模板建站推荐提高百度搜索排名工具
  • 建站源码程序山东省住房和城乡建设厅
  • 青岛网站如何制作网络推广计划方案
  • 做网站有送企业邮箱吗百度网盘下载电脑版官方下载
  • 九江做网站的公司哪里好网络营销是网上销售吗
  • 如何帮助网站吸引流量网络seo推广
  • 如何做国外网站推广如何做一个自己的网站呢
  • 网站建设背景文字百度网盘app下载安装 官方下载
  • 手机网站开发兼容性深圳百度seo整站
  • 上海网站建设哪中央电视台新闻联播
  • 静态网站建设要学什么看广告赚钱一天50元
  • 网站建站平台开发服务服务采购公告四川seo排名
  • 做临时工看哪个网站佛山旺道seo优化
  • 网站开发经典案例在线识别图片来源
  • 兰州做网站公司网站快照优化公司
  • 苏中建设网站网络营销首先要进行
  • 达州住房和城乡建设部网站西安seo服务公司
  • 网站建设的相关技术方案seo快速排名站外流量推广
  • 网站图片模板哪里做网站便宜
  • 网站后台管理代码黄冈网站推广软件免费下载
  • 信阳网站seo打开百度一下
  • 郑州做的比较好网站公司站长工具站长之家官网