index.vue 902 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <el-tooltip
  3. class="tooltip"
  4. effect="dark"
  5. placement="top"
  6. :open-delay="300"
  7. >
  8. <template #content>
  9. <span class="tooltip-content" :class="{split}">{{text}}</span>
  10. </template>
  11. <div class="overflow-text" :class="{split}" :style="{width}">
  12. {{text}}
  13. </div>
  14. </el-tooltip>
  15. </template>
  16. <script>
  17. export default {
  18. name: 'overflow-text',
  19. props: {
  20. text: {
  21. type: String,
  22. default: ''
  23. },
  24. width: {
  25. type: String,
  26. default: '200px'
  27. },
  28. split: {
  29. type: Boolean,
  30. default: false
  31. }
  32. }
  33. }
  34. </script>
  35. <style lang="less" scoped>
  36. .tooltip-content{
  37. display: inline-block;
  38. max-width: 300px;
  39. }
  40. .overflow-text{
  41. overflow : hidden;
  42. text-overflow: ellipsis;
  43. display: -webkit-box;
  44. -webkit-line-clamp: 2;
  45. -webkit-box-orient: vertical;
  46. }
  47. .split {
  48. word-break: keep-all;
  49. }
  50. </style>