diff --git a/examples/docs/en-US/table.md b/examples/docs/en-US/table.md index ecddf90c1..2df42644a 100644 --- a/examples/docs/en-US/table.md +++ b/examples/docs/en-US/table.md @@ -1948,7 +1948,7 @@ You can customize row index in `type=index` columns. | Attribute | Description | Type | Accepted Values | Default | |---------- |-------------- |---------- |-------------------------------- |-------- | | data | Table data | array | — | — | -| height | Table's height. By default it has an `auto` height. If its value is a number, the height is measured in pixels; if its value is a string, the height is affected by external styles | string/number | — | — | +| height | Table's height. By default it has an `auto` height. If its value is a number, the height is measured in pixels; if its value is a string, the value will be assigned to element's style.height, the height is affected by external styles | string/number | — | — | | max-height | Table's max-height. The height of the table starts from `auto` until it reaches the maxHeight limit. The `maxHeight` is measured in pixels, same as `height` | string/number | — | — | | stripe | whether Table is striped | boolean | — | false | | border | whether Table has vertical border | boolean | — | false | diff --git a/examples/docs/zh-CN/table.md b/examples/docs/zh-CN/table.md index 4e744c038..e8656e687 100644 --- a/examples/docs/zh-CN/table.md +++ b/examples/docs/zh-CN/table.md @@ -2008,7 +2008,7 @@ | 参数 | 说明 | 类型 | 可选值 | 默认值 | |---------- |-------------- |---------- |-------------------------------- |-------- | | data | 显示的数据 | array | — | — | -| height | Table 的高度,默认为自动高度。如果 height 为 number 类型,单位 px;如果 height 为 string 类型,则 Table 的高度受控于外部样式。 | string/number | — | — | +| height | Table 的高度,默认为自动高度。如果 height 为 number 类型,单位 px;如果 height 为 string 类型,则这个高度会设置为 Table 的 style.height 的值,Table 的高度会受控于外部样式。 | string/number | — | — | | max-height | Table 的最大高度 | string/number | — | — | | stripe | 是否为斑马纹 table | boolean | — | false | | border | 是否带有纵向边框 | boolean | — | false | diff --git a/packages/table/src/table-layout.js b/packages/table/src/table-layout.js index 9f229cb32..dd6449f70 100644 --- a/packages/table/src/table-layout.js +++ b/packages/table/src/table-layout.js @@ -63,9 +63,7 @@ class TableLayout { this.updateElsHeight(); } else if (typeof value === 'string') { - if (value === '') { - el.style[prop] = ''; - } + el.style[prop] = value; this.updateElsHeight(); } } diff --git a/test/unit/specs/table.spec.js b/test/unit/specs/table.spec.js index 36bd8ecc3..29cc5b53a 100644 --- a/test/unit/specs/table.spec.js +++ b/test/unit/specs/table.spec.js @@ -90,6 +90,15 @@ describe('Table', () => { }, DELAY); }); + it('height as string', done => { + const vm = createTable('height="100pt"'); + setTimeout(_ => { + expect(vm.$el.style.height).to.equal('100pt'); + destroyVM(vm); + done(); + }, DELAY); + }); + it('maxHeight', done => { const vm = createTable('max-height="134"'); setTimeout(_ => {