UniTextElement
text元素对象
UniTextElement 兼容性
| Web | 微信小程序 | Android | iOS | iOS uni-app x UTS 插件 | HarmonyOS | HarmonyOS uni-app x UTS 插件 |
| 4.0 | x | 4.0 | 4.11 | 4.25 | 4.61 | 4.61 |
UniTextElement 的属性值
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
| value | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
iOS uni-app x UTS 插件
|
HarmonyOS
| | 4.0 | x | 4.0 | 4.11 | 4.25 | - |
| 只读属性 text元素的文案内容 |
UniTextElement 的方法
| Web | 微信小程序 | Android | iOS | iOS uni-app x UTS 插件 | HarmonyOS |
| 4.0 | x | 4.0 | 4.11 | 4.25 | - |
返回值
参见
setTextLayout(layout: UniTextLayout): void
设置文本内容
setTextLayout 兼容性
| Web | 微信小程序 | Android | iOS | iOS uni-app x UTS 插件 | HarmonyOS |
| x | x | 4.81 | x | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| layout | UniTextLayout | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| 文本对象 |
UniTextLayout 的方法
setText(text: string): void
setText
设置文本
setText 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| text | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
setColor(color: string): void
setColor
设置文本颜色
setColor 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| color | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
setFontFamily(family: string): void
setFontFamily
设置字体名称
setFontFamily 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| family | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
setFontSize(size: string): void
setFontSize
设置字体大小
setFontSize 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| size | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
setFontStyle(style: string): void
setFontStyle
设置字体样式
setFontStyle 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| style | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
setFontWeight(weight: string): void
setFontWeight
设置字体粗细
setFontWeight 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| weight | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
setLineHeight(height: string): void
setLineHeight
设置行高
setLineHeight 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| height | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
setTextAlign(align: string): void
setTextAlign
设置文字水平对齐方式
setTextAlign 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| align | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
setTextOverflow(overflow: string): void
setTextOverflow
设置文字溢出裁剪方式
setTextOverflow 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| overflow | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
setTextShadow(shadow: string): void
setTextShadow
设置文字阴影
setTextShadow 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| shadow | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
setTextDecorationLine(decorationLine: string): void
setTextDecorationLine
设置文本修饰类型
setTextDecorationLine 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| decorationLine | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
setWhiteSpace(whiteSpace: string): void
setWhiteSpace
设置处理空白字符
setWhiteSpace 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| whiteSpace | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| |
append(layout: UniTextLayout): void
append
添加子文本对象
append 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| layout | UniTextLayout | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| 文本对象 |
measure(constraint: UniLayoutConstraintSize): UniLayoutSize
measure
测量文本大小
measure 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS |
| x | x | 4.81 | x | - |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| constraint | UniLayoutConstraintSize | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | - | x | - |
| 布局约束大小 |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 | | minWidth | number | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | 4.81 | x | - |
| 元素最小宽度,逻辑像素值 可选值,不设置则认为没有最小宽度 | | maxWidth | number | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | 4.81 | x | - |
| 元素最大宽度,逻辑像素值 可选值,不设置则认为可以无限宽 | | minHeight | number | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | 4.81 | x | - |
| 元素最小高度,逻辑像素值 可选值,不设置则认为没有最小高度 | | maxHeight | number | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | 4.81 | x | - |
| 元素最大高度,逻辑像素值 可选值,不设置则认为可以无限高 |
|
返回值
| 类型 | 描述 |
| UniLayoutSize | 布局大小 |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 | | width | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | 4.81 | x | - |
| 元素宽度,逻辑像素值 | | height | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | 4.81 | x | - |
| 元素高度,逻辑像素值 |
|
参见
getContentSize(): UniLayoutSize
获取内容宽高
getContentSize 兼容性
| Web | 微信小程序 | Android | iOS | iOS uni-app x UTS 插件 | HarmonyOS |
| x | x | 4.81 | x | x | - |
返回值
| 类型 | 描述 |
| UniLayoutSize | 布局大小 |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 | | width | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | 4.81 | x | - |
| 元素宽度,逻辑像素值 | | height | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | x | 4.81 | x | - |
| 元素高度,逻辑像素值 |
|
参见