# Text 文字
排版文本:級別(h1~h6 / p / caption)、語義色與布林修飾,多行省略與複製按鈕。級別決定渲染標籤(caption 渲染為 span 走行內小字)。
文字
<template>
<div class="demo-col" style="gap: 18px; max-width: 640px">
<div class="demo-row" style="gap: 16px; flex-wrap: wrap; align-items: baseline">
<LhText level="h1">標題一</LhText>
<LhText level="h3">標題三</LhText>
<LhText level="caption">輔助說明小字</LhText>
</div>
<div class="demo-row" style="gap: 16px; flex-wrap: wrap; align-items: baseline">
<LhText type="secondary">次要文本</LhText>
<LhText type="success">成功</LhText>
<LhText type="warning">警告</LhText>
<LhText type="danger">危險</LhText>
</div>
<div class="demo-row" style="gap: 16px; flex-wrap: wrap; align-items: baseline">
<LhText strong>加粗</LhText>
<LhText italic>斜體</LhText>
<LhText underline>下劃線</LhText>
<LhText mark>標記高亮</LhText>
<LhText code>code</LhText>
<LhText disabled>停用</LhText>
</div>
<div class="demo-row" style="flex-direction: column; gap: 8px; align-items: stretch">
<LhText :ellipsis="2">
多行省略:水墨畫講究「墨分五色」,一張宣紙之上,焦濃重淡清層層暈染,
山有骨、水有韻,留白處亦是畫——此段文字超過兩行時自動截斷並以省略號收尾。
</LhText>
<LhText copyable>點選右側按鈕複製這段文案</LhText>
</div>
</div>
</template>
<script>
export default {
data: () => ({}),
}
</script>
# Props
| 屬性 | 說明 | 類型 | 預設值 |
|---|---|---|---|
| level | 標題級別與段落形態:h1~h6 標題、p 正文、caption 行內小字 | 'h1' \| 'h2' \| 'h3' \| 'h4' \| 'h5' \| 'h6' \| 'p' \| 'caption' | 'p' |
| type | 語義色:default 常規、secondary 次要、其餘為狀態色 | 'default' \| 'secondary' \| 'success' \| 'warning' \| 'danger' | 'default' |
| strong / italic / underline / mark / code | 加粗 / 斜體 / 下劃線 / 標記高亮 / 程式碼風格 | boolean | false |
| ellipsis | 省略:true 單行省略,數字按行數截斷(上限 10) | boolean \| number | false |
| copyable | 追加複製按鈕,點選寫入剪貼簿並短暫切換「已複製」 | boolean | false |
| copyLabel | 複製按鈕的無障礙名稱(未傳時取語言包 text.copy / text.copied) | string | — |
| disabled | 停用:文本灰化、不複製 | boolean | false |
| tag | 自訂渲染標籤(預設按 level) | string | — |
| sx | sx 快速版面配置 | — | — |
# Events
| 事件 | 說明 | 回呼參數 |
|---|---|---|
| copy | 複製按鈕點選時觸發 | (text: string) |
# Slots
| 名稱 | 說明 |
|---|---|
| default | 文本內容(複製時取其 textContent) |
# 無障礙
- copyable 時輸出
aria-labelledby關聯複製按鈕,文案進入可達名稱
Copyright © 2024-2026 风默文学 | 宁ICP备2024006574号 |
苏公网安备32040002010537