elementui组件库tab页签改造

1,473 阅读1分钟

image.png

/deep/ .el-tabs {
  padding: 0 15px;

  .el-tabs__item {
    height: 36px;
    line-height: 36px;
    border: 1px solid #bbbfcc;
    border-radius: 36px;
    margin: 0 8px;
    color: #666;

    &.is-active {
      color: rgba(52, 128, 255, 1);
      border-color: rgba(52, 128, 255, 1);
      background-color: rgba(52, 128, 255, 0.1);
      // font-weight: 600;
    }
  }

  &.el-tabs--top {
    .el-tabs__item.is-top:nth-child(2) {
      padding-left: 20px;
      margin-left: 0;
    }
    .el-tabs__item.is-top:last-child {
      padding-right: 20px;
    }
  }

  .el-tabs__active-bar {
    height: 4px;
    border-radius: 4px;
    // transform: translateX(136px) !important;
  }

  .el-tabs__nav-wrap::after {
    // display: none;
    position: relative;
    display: block;
    margin-top: 15px;
    background-color: #f0f0f0;
  }

  .el-tabs__content {
    padding-right: 0;
    > div.el-tab-pane {
      overflow-y: auto;
      // padding-right: 15px;
    }
    > div.el-tab-pane:not([aria-labelledby="tab-flow"]) {
      min-height: 250px;
    }
  }
}

 @tab-click="handleClick"
 
 handleClick() {
      if (this.currentTab === "2") {
        const el = document.getElementsByClassName("el-tabs__active-bar");
        this.$nextTick(() => {
          el[0].style.cssText = "width: 56px; transform: translateX(136px);";
        });
      }
    }