<template>
  <el-tooltip
    class="tooltip"
    effect="dark"
    placement="top"
    :open-delay="300"
  >
    <template #content>
      <span class="tooltip-content" :class="{split}">{{text}}</span>
    </template>
    <div class="overflow-text" :class="{split}" :style="{width}">
      {{text}}
      </div>
  </el-tooltip>
</template>
<script>
export default {
  name: 'overflow-text',
  props: {
    text: {
      type: String,
      default: ''
    },
    width: {
      type: String,
      default: 'auto'
    },
    split: {
      type: Boolean,
      default: false
    }
  }
}
</script>
<style lang="less" scoped>
.tooltip-content{
  display: inline-block;
  max-width: 300px;
  width: 100%;
}
  .overflow-text{
    overflow : hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    // display: -webkit-box;
    // -webkit-line-clamp: 2;
    // -webkit-box-orient: vertical;
  }
  .split {
    word-break: keep-all;
  }
</style>
