<text>
<text>是Tenon中用于文本渲染的组件
WARNING
<text>标签仅支持文本,不支持嵌套子组件
<text>标签在 Tenon 中仍然是块级元素
属性
| 属性名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| richText | Array<RichText> | [] | 待渲染的富文本 |
RichText 对象如下所示
TIP
当image属性和text属性都存在时,如果image是本地图片,会被直接显示,text会被忽略;如果image是网络图片,会首先显示text的属性值,当图片下载完成后,text将会被图片替换;如果网络图片下载失败,将一直显示text的属性值。
| 属性名 | 类型 | 默认值 | 说明 | 示例 |
|---|---|---|---|---|
| color | string | 系统默认 | 文本颜色 | color: '#000000' |
| backgroundColor | string | 系统默认 | 背景颜色 | color: '#FF0000' |
| fontFamily | string | 系统默认 | 字体 | fontFamily: 'Times New Roman' |
| fontSize | number|string | 16 | 字体大小 | fontSize: 16 | '48px' |
| fontWeight | string | 'normal' | 字体粗细 | fontWeight: 'normal' | 'bold' |
| fontStyle | string | 'normal' | 字体样式(斜体) | fontWeight: 'normal' | 'italic' |
| textDecoration | string | 'none' | 文本装饰(下划线等) | textDecoration: 'none' | 'underline' | 'line-through' |
| image | string | 图片资源(支持本地和远程图片) | image: 'http://xxx/test.jpg' | |
| imageWidth | number|string | 原始图片宽度 | 图片宽度 | imageWidth: 100 | '100px' |
| imageHeight | number|string | 原始图片高度 | 图片高度 | imageHeight: 100 | '100px' |
| imageAlign | string | 'baseline' | 图片和文字的对齐方式 | imageAlign: 'baseline' | 'top' | 'center' | 'bottom' |
| href | string | 网址链接 | href: 'http://hummer.didi.cn' | |
| hrefColor | string | 系统默认 | 网址链接的文字颜色 | hrefColor: '#0000FF' |
样式
通用样式,可参考样式介绍
专属样式如下所示:
| 属性名 | 类型 | 默认值 | 说明 | 示例 |
|---|---|---|---|---|
| color | String | 系统默认 | 文本颜色 | color: '#000000' |
| font-family | String | 系统默认 | 字体 | font-family: 'Times New Roman' |
| font-size | Number | String | 16 | 字体大小 | font-size: 16 | '48px' |
| font-weight | String | 'normal' | 字体粗细 | font-weight: 'normal' | 'bold' |
| font-style | String | 'normal' | 字体样式(斜体) | font-style: 'normal' | 'italic' |
| text-align | String | 'left' | 文本对齐方式 | text-align: 'left' | 'center' | 'right' |
| text-decoration | String | 'none' | 文本装饰(下划线等) | text-decoration: 'none' | 'underline' | 'line-through' |
| text-overflow | String | 'ellipsis' | 文本内容超出控件时的省略样式 | text-overflow: 'clip' | 'ellipsis' |
| text-line-clamp | Number | 0 | 文本行数 | text-line-clamp: 1 //单行显示text-line-clamp: 0 //不限制行数(默认) |
| letter-spacing | Number | 0 | 字间距(标准字体大小的倍数,单位是em) | letter-spacing: 0.5 |
| line-spacing-multi | Number | 1 | 行间距(倍数) | line-spacing-multi: 1.2 |
事件
通用事件,可参考事件介绍
示例
Tenon Vue
html
<!-- App.vue -->
<template>
<view>
<text>Hello World!</text>
</view>
</template>
<script>
export default{}
</script>更多用法,可参考Tenon Vue 官方示例。
Tenon React
jsx
import React from "react"
import Tenon from "@hummer/tenon-react"
function TextApp() {
return (
<text>
Hello Tenon React!
</text>
);
}
Tenon.render(<TextApp />)更多用法,可参考Tenon React 官方示例。
