# 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 关联复制按钮,文案进入可达名称
最后更新: 2026/12/4 00:49:57

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