# Ellipsis 文本省略

文本省略:多行 CSS line-clamp 優先(行數經 --lh-ellipsis-rows CSS 變數驅動)、middle 中間省略走 JS 截斷(truncateMiddle);服務 「可展開 / 收起、中間省略、自訂 action」場景(純省略繼續用 Text 元件 的 ellipsis)。

文本省略(單行 / 多行 / middle / 可展開)
<template>
  <div class="demo-col" style="gap: 18px; max-width: 360px">
    <LhEllipsis :content="longText" />
    <LhEllipsis :content="longText" :rows="2" />
    <LhEllipsis :content="longText" position="middle" />
    <LhEllipsis :content="longText" :rows="2" expandable />
  </div>
</template>

<script>
export default {
  data: () => ({
    longText: 'lh-ui 是一個跨端元件庫家族,雙血脈架構,八倉齊發,文件站台十站齊備,中表裡外共十倉。',
  }),
}
</script>

# 受控展開(v-model)

<LhEllipsis
  v-model:expanded="open"
  :content="longText"
  :rows="2"
  expandable
  @change="onChange"
/>

# Props

屬性 說明 類型 預設值
content 文本內容 string —
rows 摺疊態展示行數(≥1,非法值按 1) number 1
expandable 是否可展開(渲染 action) boolean false
expanded 展開態(受控;不傳則非受控自管) boolean —
actionText action 文案(未傳走語言包 ellipsis.expand/collapse) string —
position 省略位置(end / middle;middle 僅單行,走 JS 截斷) 'end' \| 'middle' 'end'
ellipsisLabel 無障礙名稱(未傳取內容前 40 字元摘要) string —
sx sx 快速版面配置屬性 LhSxProps —

# Events

事件 說明 載荷
update:expanded 展開態變化(受控回寫) expanded: boolean
change 展開態變化(action 點選) expanded: boolean
clickAction action 被點選(與 change 同時) —

# 無障礙

action 為獨立可聚焦元素(role="button" + tabindex="0", Enter / Space 觸發),aria-expanded 隨展開態同步。

最後更新: 2026/12/4 上午12:49:57

Copyright © 2024-2026 风默文学 | 宁ICP备2024006574号 | 公安备案徽标苏公网安备32040002010537