element ui表格抖动
时间: 2023-11-30 13:43:24 浏览: 310
element ui 表格动态列显示空白bug 修复方法
5星 · 资源好评率100%
element ui表格抖动的原因是因为无论是显示列还是隐藏列,vue都需要重新计算单元格的高度和宽度,然后再重新渲染到页面上。因为这个过程被直接反馈到了页面上,所以导致了table发生闪烁。解决方法是使用element中的dolayout函数。具体实现方法如下:
```javascript
<template>
<el-table
:data="tableData"
style="width: 100%"
:key="tableKey"
ref="table"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange"
@filter-change="handleFilterChange"
@row-click="handleRowClick"
@row-dblclick="handleRowDblclick"
@row-contextmenu="handleRowContextmenu"
@header-click="handleHeaderClick"
@header-contextmenu="handleHeaderContextmenu"
@current-change="handleCurrentChange"
@header-dragend="handleHeaderDragend"
@expand-change="handleExpandChange"
@select="handleSelect"
@select-all="handleSelectAll"
@cell-mouse-enter="handleCellMouseEnter"
@cell-mouse-leave="handleCellMouseLeave"
@cell-click="handleCellClick"
@cell-dblclick="handleCellDblclick"
@cell-contextmenu="handleCellContextmenu"
@edit-disabled="handleEditDisabled"
@edit-closed="handleEditClosed"
@edit-actived="handleEditActived"
@edit-canceled="handleEditCanceled"
@edit-submit="handleEditSubmit"
@edit-command="handleEditCommand"
@edit-queue-full="handleEditQueueFull"
@edit-clear="handleEditClear"
@edit-validate="handleEditValidate"
@edit-invalid="handleEditInvalid"
@edit-valid="handleEditValid"
@edit-error="handleEditError"
@edit-reset="handleEditReset"
@edit-render="handleEditRender"
@edit-parse-value="handleEditParseValue"
@edit-format-value="handleEditFormatValue"
@edit-select-all="handleEditSelectAll"
@edit-tab="handleEditTab"
@edit-toggle-dropdown="handleEditToggleDropdown"
@edit-click="handleEditClick"
@edit-focus="handleEditFocus"
@edit-blur="handleEditBlur"
@edit-change="handleEditChange"
@edit-input="handleEditInput"
@edit-composition-start="handleEditCompositionStart"
@edit-composition-update="handleEditCompositionUpdate"
@edit-composition-end="handleEditCompositionEnd"
@edit-custom-command="handleEditCustomCommand"
@edit-custom-button-click="handleEditCustomButtonClick"
@edit-custom-cell-click="handleEditCustomCellClick"
@edit-custom-cell-mouseenter="handleEditCustomCellMouseenter"
@edit-custom-cell-mouseleave="handleEditCustomCellMouseleave"
@edit-custom-cell-contextmenu="handleEditCustomCellContextmenu"
@edit-custom-cell-dblclick="handleEditCustomCellDblclick"
@edit-custom-cell-focus="handleEditCustomCellFocus"
@edit-custom-cell-blur="handleEditCustomCellBlur"
@edit-custom-cell-keydown="handleEditCustomCellKeydown"
@edit-custom-cell-keyup="handleEditCustomCellKeyup"
@edit-custom-cell-keypress="handleEditCustomCellKeypress"
@edit-custom-cell-edit-disabled="handleEditCustomCellEditDisabled"
@edit-custom-cell-edit-closed="handleEditCustomCellEditClosed"
@edit-custom-cell-edit-actived="handleEditCustomCellEditActived"
@edit-custom-cell-edit-canceled="handleEditCustomCellEditCanceled"
@edit-custom-cell-edit-submit="handleEditCustomCellEditSubmit"
@edit-custom-cell-edit-command="handleEditCustomCellEditCommand"
@edit-custom-cell-edit-queue-full="handleEditCustomCellEditQueueFull"
@edit-custom-cell-edit-clear="handleEditCustomCellEditClear"
@edit-custom-cell-edit-validate="handleEditCustomCellEditValidate"
@edit-custom-cell-edit-invalid="handleEditCustomCellEditInvalid"
@edit-custom-cell-edit-valid="handleEditCustomCellEditValid"
@edit-custom-cell-edit-error="handleEditCustomCellEditError"
@edit-custom-cell-edit-reset="handleEditCustomCellEditReset"
@edit-custom-cell-edit-render="handleEditCustomCellEditRender"
@edit-custom-cell-edit-parse-value="handleEditCustomCellEditParseValue"
@edit-custom-cell-edit-format-value="handleEditCustomCellEditFormatValue"
@edit-custom-cell-edit-select-all="handleEditCustomCellEditSelectAll"
@edit-custom-cell-edit-tab="handleEditCustomCellEditTab"
@edit-custom-cell-edit-toggle-dropdown="handleEditCustomCellEditToggleDropdown"
@edit-custom-cell-edit-click="handleEditCustomCellEditClick"
@edit-custom-cell-edit-focus="handleEditCustomCellEditFocus"
@edit-custom-cell-edit-blur="handleEditCustomCellEditBlur"
@edit-custom-cell-edit-change="handleEditCustomCellEditChange"
@edit-custom-cell-edit-input="handleEditCustomCellEditInput"
@edit-custom-cell-edit-composition-start="handleEditCustomCellEditCompositionStart"
@edit-custom-cell-edit-composition-update="handleEditCustomCellEditCompositionUpdate"
@edit-custom-cell-edit-composition-end="handleEditCustomCellEditCompositionEnd"
@edit-custom-cell-edit-custom-command="handleEditCustomCellEditCustomCommand"
@edit-custom-cell-edit-custom-button-click="handleEditCustomCellEditCustomButtonClick"
@edit-custom-cell-edit-custom-cell-click="handleEditCustomCellEditCustomCellClick"
@edit-custom-cell-edit-custom-cell-mouseenter="handleEditCustomCellEditCustomCellMouseenter"
@edit-custom-cell-edit-custom-cell-mouseleave="handleEditCustomCellEditCustomCellMouseleave"
@edit-custom-cell-edit-custom-cell-contextmenu="handleEditCustomCellEditCustomCellContextmenu"
@edit-custom-cell-edit-custom-cell-dblclick="handleEditCustomCellEditCustomCellDblclick"
@edit-custom-cell-edit-custom-cell-focus="handleEditCustomCellEditCustomCellFocus"
@edit-custom-cell-edit-custom-cell-blur="handleEditCustomCellEditCustomCellBlur"
@edit-custom-cell-edit-custom-cell-keydown="handleEditCustomCellEditCustomCellKeydown"
@edit-custom-cell-edit-custom-cell-keyup="handleEditCustomCellEditCustomCellKeyup"
@edit-custom-cell-edit-custom-cell-keypress="handleEditCustomCellEditCustomCellKeypress"
@edit-custom-cell-edit-custom-cell-edit-disabled="handleEditCustomCellEditCustomCellEditDisabled"
@edit-custom-cell-edit-custom-cell-edit-closed="handleEditCustomCellEditCustomCellEditClosed"
@edit-custom-cell-edit-custom-cell-edit-actived="handleEditCustomCellEditCustomCellEditActived"
@edit-custom-cell-edit-custom-cell-edit-canceled="handleEditCustomCellEditCustomCellEditCanceled"
@edit-custom-cell-edit-custom-cell-edit-submit="handleEditCustomCellEditCustomCellEditSubmit"
@edit-custom-cell-edit-custom-cell-edit-command="handleEditCustomCellEditCustomCellEditCommand"
@edit-custom-cell-edit-custom-cell-edit-queue-full="handleEditCustomCellEditCustomCellEditQueueFull"
@edit-custom-cell-edit-custom-cell-edit-clear="handleEditCustomCellEditCustomCellEditClear"
@edit-custom-cell-edit-custom-cell-edit-validate="handleEditCustomCellEditCustomCellEditValidate"
@edit-custom-cell-edit-custom-cell-edit-invalid="handleEditCustomCellEditCustomCellEditInvalid"
@edit-custom-cell-edit-custom-cell-edit-valid="handleEditCustomCellEditCustomCellEditValid"
@edit-custom-cell-edit-custom-cell-edit-error="handleEditCustomCellEditCustomCellEditError"
@edit-custom-cell-edit-custom-cell-edit-reset="handleEditCustomCellEditCustomCellEditReset"
@edit-custom-cell-edit-custom-cell-edit-render="handleEditCustomCellEditCustomCellEditRender"
@edit-custom-cell-edit-custom-cell-edit-parse-value="handleEditCustomCellEditCustomCellEditParseValue"
@edit-custom-cell-edit-custom-cell-edit-format-value="handleEditCustomCellEditCustomCellEditFormatValue"
@edit-custom-cell-edit-custom-cell-edit-select-all="handleEditCustomCellEditCustomCellEditSelectAll"
@edit-custom-cell-edit-custom-cell-edit-tab="handleEditCustomCellEditCustomCellEditTab"
@edit-custom-cell-edit-custom-cell-edit-toggle-dropdown="handleEditCustomCellEditCustomCellEditToggleDropdown"
@edit-custom-cell-edit-custom-cell-edit-click="handleEditCustomCellEditCustomCellEditClick"
@edit-custom-cell-edit-custom-cell-edit-focus="handleEditCustomCellEditCustomCellEditFocus"
@edit-custom-cell-edit-custom-cell-edit-blur="handleEditCustomCellEditCustomCellEditBlur"
@edit-custom-cell-edit-custom-cell-edit-change="handleEditCustomCellEditCustomCellEditChange"
@edit-custom-cell-edit-custom-cell-edit-input="handleEditCustomCellEditCustomCellEditInput"
@edit-custom-cell-edit-custom-cell-edit-composition-start="handleEditCustomCellEditCustomCellEditCompositionStart"
@edit-custom-cell-edit-custom-cell-edit-composition-update="handleEditCustomCellEditCustomCellEditCompositionUpdate"
@edit-custom-cell-edit-custom-cell-edit-composition-end="handleEditCustomCellEditCustomCellEditCompositionEnd"
@edit-custom-cell-edit-custom-cell-edit-custom-command="handleEditCustomCellEditCustomCellEditCustomCommand"
@edit-custom-cell-edit-custom-cell-edit-custom-button-click="handleEditCustomCellEditCustomCellEditCustomButtonClick"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-click="handleEditCustomCellEditCustomCellEditCustomCellClick"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-mouseenter="handleEditCustomCellEditCustomCellEditCustomCellMouseenter"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-mouseleave="handleEditCustomCellEditCustomCellEditCustomCellMouseleave"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-contextmenu="handleEditCustomCellEditCustomCellEditCustomCellContextmenu"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-dblclick="handleEditCustomCellEditCustomCellEditCustomCellDblclick"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-focus="handleEditCustomCellEditCustomCellEditCustomCellFocus"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-blur="handleEditCustomCellEditCustomCellEditCustomCellBlur"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-keydown="handleEditCustomCellEditCustomCellEditCustomCellKeydown"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-keyup="handleEditCustomCellEditCustomCellEditCustomCellKeyup"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-keypress="handleEditCustomCellEditCustomCellEditCustomCellKeypress"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-disabled="handleEditCustomCellEditCustomCellEditCustomCellEditDisabled"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-closed="handleEditCustomCellEditCustomCellEditCustomCellEditClosed"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-actived="handleEditCustomCellEditCustomCellEditCustomCellEditActived"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-canceled="handleEditCustomCellEditCustomCellEditCustomCellEditCanceled"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-submit="handleEditCustomCellEditCustomCellEditCustomCellEditSubmit"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-command="handleEditCustomCellEditCustomCellEditCustomCellEditCommand"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-queue-full="handleEditCustomCellEditCustomCellEditCustomCellEditQueueFull"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-clear="handleEditCustomCellEditCustomCellEditCustomCellEditClear"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-validate="handleEditCustomCellEditCustomCellEditCustomCellEditValidate"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-invalid="handleEditCustomCellEditCustomCellEditCustomCellEditInvalid"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-valid="handleEditCustomCellEditCustomCellEditCustomCellEditValid"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-error="handleEditCustomCellEditCustomCellEditCustomCellEditError"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-reset="handleEditCustomCellEditCustomCellEditCustomCellEditReset"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-render="handleEditCustomCellEditCustomCellEditCustomCellEditRender"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-parse-value="handleEditCustomCellEditCustomCellEditCustomCellEditParseValue"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-format-value="handleEditCustomCellEditCustomCellEditCustomCellEditFormatValue"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-select-all="handleEditCustomCellEditCustomCellEditCustomCellEditSelectAll"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-tab="handleEditCustomCellEditCustomCellEditCustomCellEditTab"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-toggle-dropdown="handleEditCustomCellEditCustomCellEditCustomCellEditToggleDropdown"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-click="handleEditCustomCellEditCustomCellEditCustomCellEditClick"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-focus="handleEditCustomCellEditCustomCellEditCustomCellEditFocus"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-blur="handleEditCustomCellEditCustomCellEditCustomCellEditBlur"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-change="handleEditCustomCellEditCustomCellEditCustomCellEditChange"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-input="handleEditCustomCellEditCustomCellEditCustomCellEditInput"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-composition-start="handleEditCustomCellEditCustomCellEditCustomCellEditCompositionStart"
@edit-custom-cell-edit-custom-cell-edit-custom-cell-edit-composition
阅读全文