Text
子组件
可以包含Span子组件。
接口
Text(content?: string | Resource)
参数:
参数名 | 参数类型 | 必填 | 参数描述 |
content | string | Resource | 否 | 文本内容。包含子组件Span时不生效,显示Span内容,并且此时text组件的样式不生效。 默认值:' ' |
属性
名称 | 参数类型 | 描述 |
textAlign | 设置多行文本的文本对齐方式。 默认值:TextAlign.Start | |
textOverflow | {overflow: TextOverflow} | 设置文本超长时的显示方式。 默认值:{overflow: TextOverflow.Clip} 说明: 文本截断是按字截断。例如,英文以单词为最小单位进行截断,若需要以字母为单位进行截断,可在字母间添加零宽空格:\u200B。 |
maxLines | number | 设置文本的最大行数。 默认值:Infinity |
lineHeight | string | number | Resource | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。 |
decoration | { type: TextDecorationType, color?: ResourceColor } | 设置文本装饰线样式及其颜色。 默认值:{ type: TextDecorationType.None, color:Color.Black } |
baselineOffset | number | string | 设置文本基线的偏移量。 |
letterSpacing | number | string | 设置文本字符间距。 |
minFontSize | number | string | Resource | 设置文本最小显示字号。 |
maxFontSize | number | string | Resource | 设置文本最大显示字号。 |
textCase | 设置文本大小写。 默认值:TextCase.Normal |
说明
不支持Text内同时存在文本内容和Span子组件。(如果同时存在,只显示Span内的内容)。
Button
子组件
可以包含单个子组件。
接口
方法1: Button(options?: {type?: ButtonType, stateEffect?: boolean})
参数:
参数名 | 参数类型 | 必填 | 参数描述 |
type | ButtonType | 否 | 描述按钮显示样式。 默认值:ButtonType.Capsule |
stateEffect | boolean | 否 | 按钮按下时是否开启按压态显示效果,当设置为false时,按压效果关闭。。 默认值:true |
方法2: Button(label?: ResourceStr, options?: { type?: ButtonType, stateEffect?: boolean })
使用文本内容创建相应的按钮组件,此时Button无法包含子组件。
参数:
参数名 | 参数类型 | 必填 | 参数描述 |
label | 否 | 按钮文本内容。 | |
options | { type?: ButtonType, stateEffect?: boolean } | 否 | 见方法1参数说明。 |
属性
名称 | 参数类型 | 描述 |
type | ButtonType | 设置Button样式。 默认值:ButtonType.Capsule |
stateEffect | boolean | 按钮按下时是否开启按压态显示效果,当设置为false时,按压效果关闭。 默认值:true |
ButtonType枚举说明
名称 | 描述 |
Capsule | 胶囊型按钮(圆角默认为高度的一半)。 |
Circle | 圆形按钮。 |
Normal | 普通按钮(默认不带圆角)。 |
说明
按钮圆角通过通用属性borderRadius(不支持通过border接口设置圆角)。
当按钮类型为Capsule时,borderRadius设置不生效,按钮圆角始终为高度的一半。
当按钮类型为Circle时,borderRadius即为按钮半径,若未设置borderRadius按钮半径则为宽、高中较小值的一半。
按钮文本通过通用文本样式进行设置。