Commit 76ae3e8853e64dc64d138f665b389a1ba4962035
1 parent
5465ae45
fix #5380
Showing
2 changed files
with
14 additions
and
2 deletions
Show diff stats
src/components/table/table-body.vue
| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | <table-tr |
| 9 | 9 | :draggable="draggable" |
| 10 | 10 | :row="row" |
| 11 | - :key="row._rowKey" | |
| 11 | + :key="rowKey ? row._rowKey : index" | |
| 12 | 12 | :prefix-cls="prefixCls" |
| 13 | 13 | @mouseenter.native.stop="handleMouseIn(row._index)" |
| 14 | 14 | @mouseleave.native.stop="handleMouseOut(row._index)" |
| ... | ... | @@ -31,7 +31,7 @@ |
| 31 | 31 | </table-tr> |
| 32 | 32 | <tr v-if="rowExpanded(row._index)" :class="{[prefixCls + '-expanded-hidden']: fixed}"> |
| 33 | 33 | <td :colspan="columns.length" :class="prefixCls + '-expanded-cell'"> |
| 34 | - <Expand :key="row._rowKey" :row="row" :render="expandRender" :index="row._index"></Expand> | |
| 34 | + <Expand :key="rowKey ? row._rowKey : index" :row="row" :render="expandRender" :index="row._index"></Expand> | |
| 35 | 35 | </td> |
| 36 | 36 | </tr> |
| 37 | 37 | </template> |
| ... | ... | @@ -63,6 +63,10 @@ |
| 63 | 63 | draggable: { |
| 64 | 64 | type: Boolean, |
| 65 | 65 | default: false |
| 66 | + }, | |
| 67 | + rowKey: { | |
| 68 | + type: Boolean, | |
| 69 | + default: false | |
| 66 | 70 | } |
| 67 | 71 | }, |
| 68 | 72 | computed: { | ... | ... |
src/components/table/table.vue
| ... | ... | @@ -21,6 +21,7 @@ |
| 21 | 21 | :styleObject="tableStyle" |
| 22 | 22 | :columns="cloneColumns" |
| 23 | 23 | :data="rebuildData" |
| 24 | + :row-key="rowKey" | |
| 24 | 25 | :columns-width="columnsWidth" |
| 25 | 26 | :obj-data="objData"></table-body> |
| 26 | 27 | </div> |
| ... | ... | @@ -59,6 +60,7 @@ |
| 59 | 60 | :styleObject="fixedTableStyle" |
| 60 | 61 | :columns="leftFixedColumns" |
| 61 | 62 | :data="rebuildData" |
| 63 | + :row-key="rowKey" | |
| 62 | 64 | :columns-width="columnsWidth" |
| 63 | 65 | :obj-data="objData"></table-body> |
| 64 | 66 | </div> |
| ... | ... | @@ -84,6 +86,7 @@ |
| 84 | 86 | :styleObject="fixedRightTableStyle" |
| 85 | 87 | :columns="rightFixedColumns" |
| 86 | 88 | :data="rebuildData" |
| 89 | + :row-key="rowKey" | |
| 87 | 90 | :columns-width="columnsWidth" |
| 88 | 91 | :obj-data="objData"></table-body> |
| 89 | 92 | </div> |
| ... | ... | @@ -200,6 +203,11 @@ |
| 200 | 203 | return oneOf(value, ['dark', 'light']); |
| 201 | 204 | }, |
| 202 | 205 | default: 'dark' |
| 206 | + }, | |
| 207 | + // #5380 开启后,:key 强制更新,否则使用 index | |
| 208 | + rowKey: { | |
| 209 | + type: Boolean, | |
| 210 | + default: false | |
| 203 | 211 | } |
| 204 | 212 | }, |
| 205 | 213 | data () { | ... | ... |