解决element ui table 闪烁一下
时间: 2023-06-04 22:02:24 浏览: 841
针对element ui table闪烁一下的问题,可以尝试以下方法:
1. 在table组件中设置 :row-key="key",key为表格中每行数据的唯一标识,可以是数据中的某个字段或者使用v-for中的index。
2. 在table组件中设置 :loading="isLoading",isLoading为控制loading状态的变量。
3. 在table组件上加上样式,禁止table中内容的选中状态,即添加CSS样式 user-select: none;。
4. 确认 table 组件的父元素没有设置 opacity 或 filter 属性,这两个属性会触发浏览器对页面进行 repaint。
如果以上方法无法解决问题,可以考虑升级到最新版本的element-ui组件库。
相关问题
element ui隐藏table滚动条
### 回答1:
可以通过设置表格的样式来隐藏滚动条,具体方法如下:
1. 在表格的外层容器上设置样式 overflow: hidden;
2. 在表格的 tbody 上设置样式 overflow-y: scroll;
这样就可以隐藏表格的滚动条了。
### 回答2:
Element UI 是一个基于 Vue.js 的 UI 库,它提供了丰富的组件,包括表格组件。在使用 Element UI 表格组件时,有时候需要隐藏表格的滚动条,这可以通过以下步骤完成:
1. 找到 Element UI 表格组件的容器元素,一般是一个 class 为 el-table 的 div 元素。
2. 在该容器元素的样式中设置 overflow 属性为 hidden,这样便可隐藏表格的滚动条。
例如,如果要隐藏 id 为 my-table 的表格组件的滚动条,可以在样式中添加如下代码:
```css
#my-table .el-table {
overflow: hidden;
}
```
这样便可成功地隐藏表格组件的滚动条。
另外,如果想要隐藏表头和表格内容的滚动条,可以将 overflow 属性应用到 el-table__header-wrapper 和 el-table__body-wrapper 元素,例如:
```css
#my-table .el-table__header-wrapper,
#my-table .el-table__body-wrapper {
overflow: hidden;
}
```
这样便可同时隐藏表头和表格内容的滚动条。
总之,Element UI 表格组件的滚动条隐藏,可以通过设置容器元素的 overflow 属性为 hidden 实现。
### 回答3:
在 Element UI 中,我们可以使用 el-table 组件来显示数据表格,而当数据量较大时,就会出现滚动条。如果我们希望隐藏滚动条,可以采取以下方法:
方法1:CSS 样式方式
1.在 el-table 标签上加上 style="overflow:hidden;",这样能够隐去直接展示的滚动条,但是在鼠标滚动滚轮的时候,仍会出现默认的浏览器滚动条,不能达到完全隐藏的效果。
2.给 el-table 标签外层添加一个包裹层,如 <div class="table-wrapper">,并设置其样式为 overflow:hidden;。同时,将 el-table 的高度设置为最大值:max-height: none; height: auto;。这样展示时就能完全隐藏滚动条。
3.但是,由于这种方法需要额外添加包裹层,所以可能会减少页面的美观度,不够简洁。
方法2:JS 方式
1.在页面加载完成后,获取 el-table 的 class 属性,如:let tableClass = document.querySelector('.el-table--scrollable-y');
2.获取到 class 属性后,为 el-table 隐藏滚动条:tableClass.style.overflowY = 'hidden';
3.但是,使用 JS 方法隐藏滚动条需要在页面加载后再操作,如果操作晚了容易引起页面的闪烁。同时,这种方式虽然能够隐藏滚动条,但是并没有解决滚动的问题,使用鼠标滚轮时仍会触发滚动事件。
总结来说,以上两种方法中,CSS 样式方式更为简洁,但是需要额外添加包裹层,而 JS 方式虽然容易实现,但是需要注意操作的时机。在实际开发中,可以根据具体需求和场景选择合适的方法来隐藏滚动条。
element ui表格抖动
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
阅读全文