Text

文本的常见操作

基础用法

由 type 属性来选择 Text 的类型。

DefaultPrimarySuccessInfoWarningDanger

尺寸

使用 size 属性配置尺寸,可选的尺寸大小有: large, default 或 small

LargeDefaultSmall

省略

通过 truncated 属性,在文本超过视图或最大宽度设置时展示省略符。通过 line-clamp 属性控制多行的样式 Starting from version 2.14.6, isTruncated is exposed to indicate whether the text is truncated. You can use it to show a tooltip only when truncation occurs.

Self element set width 100px
Squeezed by parent element
The -webkit-line-clamp CSS property
allows limiting of the contents of
a block to the specified number of lines.
Show tooltip only when the text is truncated

覆盖

使用属性 tag 覆盖元素

span

This is a paragraph.

Bold
Italic
This is subscript
This is superscript
Inserted
Deleted
Marked

混合使用

混合使用 Text 组件

Element-Plus
Rate
This is text mixed icon and component

Text API

Text Attributes

属性名说明类型默认值
type文本类型enum—
size文本尺寸enum—
truncated是否单行溢出省略booleanfalse
lineClamp最大行数,传入即启用多行省略number / string—
tag渲染的标签名,如 p / b / i / sub / sup / ins / del / markstringspan
className / style根节点类名与样式string / CSSProperties—
title原生 title,传入后不再自动计算string—

Text Events

无。

Text Slots

插槽名说明React 写法
default文本或混排内容(文本、图标、组件)children

Exposes

无。