Commit f1dfa8ffab9ebacd028c0ff75664b1f24e8ed3e2

Authored by huanghong
1 parent 060c7958

fixed table show-header=false bug

examples/routers/table.vue
1 1 <template>
2 2 <div>
3 3 <br><br><br><br><br>
4   - <Table border :columns="columns1" height="500" :data="data1"></Table>
  4 + <Table border :columns="columns1" height="500" :data="data1"></Table>
5 5 <!-- <Table border :columns="columns1" height='300'></Table> -->
6 6 <!-- <br><br><br><br><br> -->
7 7 <!-- <Table width="550" height="200" border :columns="columns2" :data="data4"></Table> -->
... ... @@ -10,6 +10,7 @@
10 10 <!-- <br><br><br><br><br> -->
11 11 <!-- <Table border :columns="columns6" :data="data5"></Table> -->
12 12 <!-- <br><br><br><br><br> -->
  13 + <Table border :show-header='false' :columns="columns7" height="200" :data="data7"></Table>
13 14 <Table border :columns="columns7" height="240" :data="data7"></Table>
14 15 <!-- <br><br><br><br><br> -->
15 16 <!-- <Table border :columns="columns8" :data="data7" height="200"></Table> -->
... ...
package.json
... ... @@ -20,6 +20,7 @@
20 20 ],
21 21 "scripts": {
22 22 "dev": "webpack-dev-server --content-base test/ --open --inline --hot --compress --history-api-fallback --port 8081 --config build/webpack.dev.config.js",
  23 + "dev:s": "webpack-dev-server --content-base test/ --open --inline --hot --compress --history-api-fallback --port 8081 --host 0.0.0.0 --config build/webpack.dev.config.js",
23 24 "dist:style": "gulp --gulpfile build/build-style.js",
24 25 "dist:dev": "webpack --config build/webpack.dist.dev.config.js",
25 26 "dist:prod": "webpack --config build/webpack.dist.prod.config.js",
... ...
src/components/table/table.vue
... ... @@ -573,9 +573,13 @@
573 573 }
574 574 },
575 575 fixedBody (){
576   - this.headerWidth = this.$refs.header.children[0].offsetWidth;
577   - this.headerHeight = this.$refs.header.children[0].offsetHeight;
578   - this.showHorizontalScrollBar = this.headerWidth>this.$refs.header.offsetWidth;
  576 + if (this.$refs.header) {
  577 + this.headerWidth = this.$refs.header.children[0].offsetWidth;
  578 + this.headerHeight = this.$refs.header.children[0].offsetHeight;
  579 + this.showHorizontalScrollBar = this.headerWidth>this.$refs.header.offsetWidth;
  580 +
  581 + }
  582 +
579 583 if (!this.$refs.tbody || !this.data || this.data.length === 0) {
580 584 this.showVerticalScrollBar = false;
581 585 }
... ... @@ -584,6 +588,10 @@
584 588 let bodyEl = bodyContentEl.parentElement;
585 589 let bodyContentHeight = bodyContentEl.offsetHeight;
586 590 let bodyHeight = bodyEl.offsetHeight;
  591 +
  592 + if (!this.$refs.header) {
  593 + this.showHorizontalScrollBar = bodyEl.offsetWidth < bodyContentEl.offsetWidth;
  594 + }
587 595  
588 596 this.showVerticalScrollBar = this.bodyHeight? bodyHeight - (this.showHorizontalScrollBar?this.scrollBarWidth:0) < bodyContentHeight : false;
589 597  
... ... @@ -597,7 +605,7 @@
597 605 }else{
598 606 bodyEl.classList.remove(this.prefixCls +'-overflowX');
599 607 }
600   - }
  608 + }
601 609 },
602 610  
603 611 hideColumnFilter () {
... ...