美文网首页
element表格超出提示toast

element表格超出提示toast

作者: 小溪流jun | 来源:发表于2021-09-14 08:59 被阅读0次
    <template>
      <div class="text-tooltip">
        <el-tooltip
          class="item"
          effect="dark"
          :disabled="isShowTooltip"
          placement="top"
        >
          <div slot="content">{{ content | stringFilter }}</div>
          <p class="over-flow" :class="className" @mouseover="onMouseOver(refName)">
            <span :ref="refName" class="txt">{{ content || '-' }}</span>
          </p>
        </el-tooltip>
      </div>
    </template>
    <script>
    export default {
      props: {
        content: {
          type: String,
          default: () => {
            return ''
          },
        },
        className: {
          type: String,
          default: () => {
            return ''
          },
        },
        refName: {
          type: String,
          default: () => {
            return ''
          },
        },
      },
      data() {
        return {
          isShowTooltip: true,
        }
      },
      filters: {
        stringFilter(str) {
          return [undefined, null, ' '].includes(str) ? '--' : str
        },
      },
      methods: {
        onMouseOver(str) {
          let parentHeight = this.$refs[str].parentNode.offsetHeight
          let contentHeight = this.$refs[str].offsetHeight
          if (contentHeight > parentHeight) {
            this.isShowTooltip = false
          } else {
            this.isShowTooltip = true
          }
        },
      },
    }
    </script>
    <style lang="scss">
    @mixin xxl-ellipsis-two {
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      /* autoprefixer: ignore next */
      -webkit-box-orient: vertical;
      word-break: break-word;
    }
    @mixin xxl-ellipsis {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .over-flow {
      @include xxl-ellipsis-two;
    }
    .width {
      width: 100%;
    }
    p {
      margin: 0;
    }
    </style>
    
    

    相关文章

      网友评论

          本文标题:element表格超出提示toast

          本文链接:https://www.haomeiwen.com/subject/rhtcgltx.html