From f4afdab43047f8cb709baa009c4dfcc5e6970a24 Mon Sep 17 00:00:00 2001 From: feverdestiny Date: Fri, 31 May 2019 18:47:44 +0800 Subject: [PATCH] Table: fix set height to string ivalid problem (#15806) --- packages/table/src/table-layout.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/table/src/table-layout.js b/packages/table/src/table-layout.js index 5b78519da8..16165fe4a0 100644 --- a/packages/table/src/table-layout.js +++ b/packages/table/src/table-layout.js @@ -1,6 +1,5 @@ import Vue from 'vue'; import scrollbarWidth from 'element-ui/src/utils/scrollbar-width'; -import { parseHeight } from './util'; class TableLayout { constructor(options) { @@ -42,7 +41,7 @@ class TableLayout { updateScrollY() { const height = this.height; - if (height === null) return; + if (typeof height !== 'string' && typeof height !== 'number') return; const bodyWrapper = this.table.bodyWrapper; if (this.table.$el && bodyWrapper) { const body = bodyWrapper.querySelector('.el-table__body'); @@ -53,13 +52,19 @@ class TableLayout { setHeight(value, prop = 'height') { if (Vue.prototype.$isServer) return; const el = this.table.$el; - value = parseHeight(value); + if (typeof value === 'string' && /^\d+$/.test(value)) { + value = Number(value); + } this.height = value; if (!el && (value || value === 0)) return Vue.nextTick(() => this.setHeight(value, prop)); - if (value) { - el.style[prop] = `${value}px`; + if (typeof value === 'number') { + el.style[prop] = value + 'px'; + + this.updateElsHeight(); + } else if (typeof value === 'string') { + el.style[prop] = value; this.updateElsHeight(); } }