Skip to content

Text 文本

文本组件,用于展示文本信息。

基本用法

设置 text 设置文本内容。推荐您使用:text='value'的形式。

html
<wui-text
  text="芦叶满汀洲,寒沙带浅流。二十年重过南楼。柳下系船犹未稳,能几日,又中秋。黄鹤断矶头,故人曾到否?旧江山浑是新愁。欲买桂花同载酒,终不似,少年游。"
></wui-text>

设置主题

通过type参数设置文本主题,我们提供了五类属性:primary error success warning default-默认

html
<wui-text type="primary" text="主色"></wui-text>
<wui-text type="error" text="错误"></wui-text>
<wui-text type="success" text="成功"></wui-text>
<wui-text type="warning" text="警告"></wui-text>
<wui-text text="默认"></wui-text>

自定义字体颜色

设置 color 属性。

html
<wui-text
  text="芦叶满汀洲,寒沙带浅流。二十年重过南楼。柳下系船犹未稳,能几日,又中秋。黄鹤断矶头,故人曾到否?旧江山浑是新愁。欲买桂花同载酒,终不似,少年游。"
  color="#36B8C2"
></wui-text>

是否粗体

设置 bold 属性。

html
<wui-text
  text="芦叶满汀洲,寒沙带浅流。二十年重过南楼。柳下系船犹未稳,能几日,又中秋。黄鹤断矶头,故人曾到否?旧江山浑是新愁。欲买桂花同载酒,终不似,少年游。"
  bold
></wui-text>

字体大小

设置 size 属性。

html
<wui-text
  text="芦叶满汀洲,寒沙带浅流。二十年重过南楼。柳下系船犹未稳,能几日,又中秋。黄鹤断矶头,故人曾到否?旧江山浑是新愁。欲买桂花同载酒,终不似,少年游。"
  size="16px"
></wui-text>

脱敏

设置 format 属性,当 modephone``name时生效。

html
<wui-text text="李四" mode="name" :format="true"></wui-text>
<wui-text text="张长三" mode="name" :format="true"></wui-text>
<wui-text text="18888888888" mode="phone" :format="true"></wui-text>

lines

设置 lines 属性,文本显示的行数,如果设置,超出此行数,将会显示省略号。最大值为 5。

html
<wui-text :text="text" :lines="2" size="16px"></wui-text>

lineHeight

设置 lineHeight 文本行高。

html
<wui-text :text="text" lineHeight="20px"></wui-text>

前后插槽

设置 prefix suffix 插槽。

html
<wui-text text="12345678901" mode="phone" format type="primary" prefix="Prefix" suffix="Suffix" />

<wui-text text="12345678901" mode="phone" format type="primary">
  <template #prefix>
    <text>Prefix</text>
  </template>
  <template #suffix>Suffix</template>
</wui-text>

金额

设置 mode="price"

html
<wui-text text="16354.156" mode="price" type="success" decoration="line-through" prefix="¥" />

文字装饰

设置 decoration 文字装饰,下划线,中划线等。

html
<wui-text :text="text" type="warning" decoration="underline" />

事件

html
<wui-text
  text="芦叶满汀洲,寒沙带浅流。二十年重过南楼。柳下系船犹未稳,能几日,又中秋。黄鹤断矶头,故人曾到否?旧江山浑是新愁。欲买桂花同载酒,终不似,少年游。"
  @click="clickTest"
></wui-text>
typescript
function clickTest() {
  console.log(1)
}

Attributes

参数说明类型可选值默认值最低版本
type主题类型string'primary' / 'error' / 'warning' / 'success'default-
text文字string / number--
size字体大小string---
mode文本处理的匹配模式string'text-普通文本' / 'date - 日期' / 'phone - 手机号' / 'name - 姓名' / 'price - 金额'text-+
bold是否粗体,默认 normalboolean-false-
format是否脱敏boolean当 mode 为 phone 和 name 时生效false-
color文字颜色string---
lines文本显示的行数,如果设置,超出此行数,将会显示省略号。最大值为 5。Number---
lineHeight文本行高string--
decoration文字装饰,下划线,中划线等stringunderline/line-through/overline-+
prefix前置插槽string--+
suffix后置插槽string--+

Events

事件名称说明参数最低版本
click标签点击时触发event-

外部样式类

类名说明最低版本
custom-class根节点样式-
custom-style根节点样式-

源代码

文档
组件

Released under the MIT License.

Released under the MIT License.