当前位置:   article > 正文

【element-ui】Bug集合_element ui漏洞

element ui漏洞

1、el-dialog中el-select下拉框无法展示 

在el-dialog与el-select配合使用的时候,我们会发现el-select无法下拉,其实这问题就是下拉框层级不够和样式问题,那如何解决呢?下面就是解决方式。

  1. <template>
  2. <el-select
  3. :popper-append-to-body="false"
  4. popper-class="select-popper">
  5. </el-select>
  6. </template>
  7. <style lang="scss" scoped>
  8. ::v-deep .select-popper{
  9. z-index: 9999 !important;
  10. top: auto !important;
  11. left: auto !important
  12. }
  13. </style>

2、el-form表单el-radio-group校验未生效

  1. <el-form>
  2. <el-form-item prop="radio">
  3. <el-radio-group v-model="form.radio">
  4. <el-radio :label="1"></el-radio>
  5. <el-radio :label="2"></el-radio>
  6. </el-radio-group>
  7. </el-form-item>
  8. </el-from>

这个直接说结论,你的form.radio 必须为空字符,才能使require生效!

 3、el-dialog中的el-select和el-tree 组件点击按钮时,el-dialog会晃动

解决方法:

  1. .el-dialog{
  2. transform: none;
  3. left: 0;
  4. position: relative;
  5. margin: 0 auto;
  6. }

4、el-table 设置max-height 后底边框消失

 没有设置最大高度,则有底边框,设置了则没有底边框

解决方法:

要设置最大高度时,才修改el-table 的border-bottom 样式,不设置最大高度时,则不需要加任何代码

  1. <el-table
  2. :data="data"
  3. border
  4. :style="{
  5. borderBottom: maxHeight === 'auto' ? 'none' : '1px solid #e8eded'
  6. }"
  7. :max-height="maxHeight"
  8. />
  9. <script>
  10. export default{
  11. data() {
  12. maxHeight: 'auto'
  13. }
  14. }
  15. </script>

5、el-input[type="number"] 时去除上下计数器 

只想要输入框,并且只能自己输入数字,不想要上下计数器去点击改变数值

解决方法:

  1. ::v-deep input::-webkit-outer-spin-button,
  2. ::v-deep input::-webkit-inner-spin-button {
  3. -webkit-appearance: none !important;
  4. }

6、 el-table 出现横向滚动条导致fixed栏无法对齐

基础解决方法:

解决el-table 出现横向滚动条情况下 fixed栏与左边不对齐的情况,padding-bottom为横向滚动条高度

  1. css修改
  2. .el-table__fixed-body-wrapper {
  3.     .el-table__body {
  4.         padding-bottom: 15px;
  5.     }
  6. }
  7. js执行
  8. $refs.table.doLayout()

当你执行上述方式无法解决固定栏对齐问题时,那么来试试下面这种终极解决方法:

终极解决方法:

首先将表格内的fixed属性去掉不使用,我们自己来写固定栏效果

效果图如下:

 scss样式写法,下面fixed-4, fixed-0 是样式类名,假设有纵向滚动条,那么表格body不需要固定偏移,赋值class为fixed-0,而表格header需要固定偏移,所以赋值class为fixed-4

  1. $width: (
  2. fixed-4: 4,
  3. fixed-0: 0,
  4. );
  5. @each $key, $value in $width {
  6. .#{$key} {
  7. position: sticky !important;
  8. transition: background-color 0.25s ease;
  9. background-color: #fff;
  10. right: $value + px;
  11. box-shadow: -3px 0 6px rgba(0, 0, 0, 0.1);
  12. }
  13. }

在el-table表格使用中,有两属性可以控制header和body部分的class名的喔~

  1. <el-table
  2. :header-cell-class-name="headerCellClassName"
  3. :cell-class-name="cellClassName"
  4. >
  5. </el-table>
  6. header-cell-class-name:控制header class
  7. cell-class-name:控制body class
  8. 其回调都是 { row, column, rowIndex, columnIndex }
  9. methods: {
  10. cellClassName({ row, column, rowIndex, columnIndex }) {
  11. return 'fixed-0'
  12. }
  13. }

 以上方式使用后,就可以实现固定列和其他列对齐啦,那为啥会出现这种原因呢?因为el-table其本质就是两个表格,没有固定列时是一个,有固定列会多生成一个表格来展示固定列

7、el-tree 点击高亮后的颜色修改

默认样式:

但是我们需要黑色背景的话,然后点击时修改每一行的背景颜色和选中颜色,代码如下,你也可以使用::deep噢,一样的意思

  1. :global {
  2. .el-tree {
  3. background-color: #000;
  4. color: #fff;
  5. .el-tree-node__content {
  6. &:hover {
  7. background-color: #000;
  8. color: #F59A23;
  9. }
  10. }
  11. .el-tree-node:focus > .el-tree-node__content {
  12. color: #F59A23;
  13. background-color: #000;
  14. }
  15. }
  16. }

修改后效果:

8、el-tree 默认值选择

设置默认值时,如果使用default-checked-keys,则会导致在选择其他值时,该默认值会一直选中,当然你也可以选择主动置空,但是我觉得非好方法

  1. <el-tree
  2. data={props.data}
  3. props={defaultProps}
  4. node-key={defaultProps.id}
  5. default-checked-keys={defaultProps.defaultCheckedKeys}
  6. />

解决方法:

通过ref来调用setCheckedKeys方法设置默认值

 menuTree.value.setCheckedKeys([val])

  1. <el-tree
  2. ref={menuTree}
  3. data={props.data}
  4. props={defaultProps}
  5. node-key={defaultProps.id}
  6. />

------持续更新中------

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/535254
推荐阅读
相关标签
  

闽ICP备14008679号