diff --git a/src/components/table/cell.vue b/src/components/table/cell.vue
index 3eff914b..79142c70 100644
--- a/src/components/table/cell.vue
+++ b/src/components/table/cell.vue
@@ -14,8 +14,8 @@
-
- {{ row[column.key] }}
+
+ {{ row[column.key] }}
{{row[column.key]}}
@@ -75,8 +75,7 @@
renderType: '',
uid: -1,
context: this.$parent.$parent.$parent.currentContext,
- showTooltip: false, // 鼠标滑过overflow文本时,再检查是否需要显示
- tooltipShow: false
+ showTooltip: false // 鼠标滑过overflow文本时,再检查是否需要显示
};
},
computed: {
@@ -153,16 +152,12 @@
},
handleTooltipIn () {
const $content = this.$refs.content;
- this.showTooltip = $content.scrollWidth > $content.offsetWidth;
- },
- handleTooltipOut () {
- this.showTooltip = false;
- },
- handleTooltipShow () {
- this.tooltipShow = true;
- },
- handleTooltipHide () {
- this.tooltipShow = false;
+ let range = document.createRange();
+ range.setStart($content, 0);
+ range.setEnd($content, $content.childNodes.length);
+ const rangeWidth = range.getBoundingClientRect().width;
+ this.showTooltip = rangeWidth > $content.offsetWidth;
+ range = null;
},
handleToggleTree () {
this.$parent.$parent.$parent.toggleTree(this.row._rowKey);
diff --git a/src/components/table/table.vue b/src/components/table/table.vue
index 99d172d5..ef6ccf71 100644
--- a/src/components/table/table.vue
+++ b/src/components/table/table.vue
@@ -244,6 +244,11 @@
},
default: 'dark'
},
+ // 4.5.0
+ tooltipMaxWidth: {
+ type: Number,
+ default: 300
+ },
// #5380 开启后,:key 强制更新,否则使用 index
// 4.1 开始支持 String,指定具体字段
rowKey: {