Commit a81dc06c7d54d4298824aab9906c9581a3e57680

Authored by 梁灏
1 parent d0e206c5

publish 0.9.9-rc-4

optimizing Table performance
package.json
1 1 {
2 2 "name": "iview",
3   - "version": "0.9.9-rc-3",
  3 + "version": "0.9.9-rc-4",
4 4 "title": "iView",
5 5 "description": "A high quality UI components Library with Vue.js",
6 6 "homepage": "http://www.iviewui.com",
... ...
src/components/table/table.vue
... ... @@ -21,7 +21,7 @@
21 21 :columns-width="columnsWidth"
22 22 :obj-data="objData"></table-body>
23 23 </div>
24   - <div :class="[prefixCls + '-fixed']" :style="fixedTableStyle">
  24 + <div :class="[prefixCls + '-fixed']" :style="fixedTableStyle" v-if="isLeftFixed">
25 25 <div :class="[prefixCls + '-fixed-header']" v-if="showHeader">
26 26 <table-head
27 27 fixed="left"
... ... @@ -43,7 +43,7 @@
43 43 :obj-data="objData"></table-body>
44 44 </div>
45 45 </div>
46   - <div :class="[prefixCls + '-fixed-right']" :style="fixedRightTableStyle">
  46 + <div :class="[prefixCls + '-fixed-right']" :style="fixedRightTableStyle" v-if="isRightFixed">
47 47 <div :class="[prefixCls + '-fixed-header']" v-if="showHeader">
48 48 <table-head
49 49 fixed="right"
... ... @@ -226,6 +226,12 @@
226 226 }
227 227 });
228 228 return right.concat(other);
  229 + },
  230 + isLeftFixed () {
  231 + return this.columns.some(col => col.fixed && col.fixed === 'left');
  232 + },
  233 + isRightFixed () {
  234 + return this.columns.some(col => col.fixed && col.fixed === 'right');
229 235 }
230 236 },
231 237 methods: {
... ... @@ -342,8 +348,8 @@
342 348 },
343 349 handleBodyScroll (event) {
344 350 if (this.showHeader) this.$els.header.scrollLeft = event.target.scrollLeft;
345   - if (this.leftFixedColumns.length) this.$els.fixedBody.scrollTop = event.target.scrollTop;
346   - if (this.rightFixedColumns.length) this.$els.fixedRightBody.scrollTop = event.target.scrollTop;
  351 + if (this.isLeftFixed) this.$els.fixedBody.scrollTop = event.target.scrollTop;
  352 + if (this.isRightFixed) this.$els.fixedRightBody.scrollTop = event.target.scrollTop;
347 353 this.hideColumnFilter();
348 354 },
349 355 handleMouseWheel (event) {
... ...
test/routers/table.vue
... ... @@ -9,21 +9,21 @@
9 9 return {
10 10 self: this,
11 11 columns7: [
12   -// {
13   -// title: '姓名',
14   -// key: 'name',
15   -// render (row, column, index) {
16   -// return `<strong>${row.name}</strong>`;
17   -// }
18   -// },
19   -// {
20   -// title: '年龄',
21   -// key: 'age'
22   -// },
23   -// {
24   -// title: '地址',
25   -// key: 'address'
26   -// },
  12 + {
  13 + title: '姓名',
  14 + key: 'name',
  15 + render (row, column, index) {
  16 + return `<strong>${row.name}</strong>`;
  17 + }
  18 + },
  19 + {
  20 + title: '年龄',
  21 + key: 'age'
  22 + },
  23 + {
  24 + title: '地址',
  25 + key: 'address'
  26 + },
27 27 {
28 28 title: '操作',
29 29 key: 'action',
... ...