未验证 提交 1dd45d80 编写于 作者: O openharmony_ci 提交者: Gitee

!22169 文档整改

Merge pull request !22169 from 田雨/master
...@@ -309,7 +309,7 @@ deleteSpans(value?: RichEditorRange): void ...@@ -309,7 +309,7 @@ deleteSpans(value?: RichEditorRange): void
| fontSize | [Length](ts-types.md#length) \| number | 否 | 字体大小。 <br/>默认值:16fp。| | fontSize | [Length](ts-types.md#length) \| number | 否 | 字体大小。 <br/>默认值:16fp。|
| fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | 否 | 字体样式。<br/>默认值:FontStyle.Normal。 | | fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | 否 | 字体样式。<br/>默认值:FontStyle.Normal。 |
| fontWeight | [FontWeight](ts-appendix-enums.md#fontweight) \| number \| string | 否 | 字体粗细。<br/>number类型取值[100,900],取值间隔为100,默认为400,取值越大,字体越粗。<br/>string类型仅支持number类型取值的字符串形式,例如“400”,以及“bold”、“bolder”、“lighter”、“regular” 、“medium”分别对应FontWeight中相应的枚举值。<br/>默认值:FontWeight.Normal。 | | fontWeight | [FontWeight](ts-appendix-enums.md#fontweight) \| number \| string | 否 | 字体粗细。<br/>number类型取值[100,900],取值间隔为100,默认为400,取值越大,字体越粗。<br/>string类型仅支持number类型取值的字符串形式,例如“400”,以及“bold”、“bolder”、“lighter”、“regular” 、“medium”分别对应FontWeight中相应的枚举值。<br/>默认值:FontWeight.Normal。 |
| fontFamily | [ResourceStr](ts-types.md#resourcestr) \| number \| string | 否 | 设置字体列表。默认字体'HarmonyOS Sans',且当前只支持这种字体<br/>默认字体:'HarmonyOS Sans'。| | fontFamily | [ResourceStr](ts-types.md#resourcestr) \| number \| string | 否 | 设置字体列表。默认字体'HarmonyOS Sans',当前支持'HarmonyOS Sans'字体和[注册自定义字体](../apis/js-apis-font.md)<br/>默认字体:'HarmonyOS Sans'。|
| decoration | {<br/>type:&nbsp;[TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br/>color?:&nbsp;[ResourceColor](ts-types.md#resourcecolor)<br/>} | 否 | 设置文本装饰线样式及其颜色。<br />默认值:{<br/>type:&nbsp;TextDecorationType.None,<br/>color:Color.Black<br/>}。 | | decoration | {<br/>type:&nbsp;[TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br/>color?:&nbsp;[ResourceColor](ts-types.md#resourcecolor)<br/>} | 否 | 设置文本装饰线样式及其颜色。<br />默认值:{<br/>type:&nbsp;TextDecorationType.None,<br/>color:Color.Black<br/>}。 |
......
...@@ -58,6 +58,12 @@ struct SpanExample { ...@@ -58,6 +58,12 @@ struct SpanExample {
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
Text('Basic Usage').fontSize(9).fontColor(0xCCCCCC) Text('Basic Usage').fontSize(9).fontColor(0xCCCCCC)
Text() {
Span('In Line')
Span(' Component')
Span(' !')
}
Text() { Text() {
Span('This is the Span component').fontSize(12).textCase(TextCase.Normal) Span('This is the Span component').fontSize(12).textCase(TextCase.Normal)
.decoration({ type: TextDecorationType.None, color: Color.Red }) .decoration({ type: TextDecorationType.None, color: Color.Red })
...@@ -118,4 +124,4 @@ struct SpanExample { ...@@ -118,4 +124,4 @@ struct SpanExample {
} }
``` ```
![span](figures/span.png) ![Span](figures/Span.PNG)
...@@ -53,7 +53,7 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te ...@@ -53,7 +53,7 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te
| selectionMenuHidden<sup>10+</sup> | boolean | 设置长按输入框或者右键输入框时,是否弹出文本选择菜单。<br />默认值:false | | selectionMenuHidden<sup>10+</sup> | boolean | 设置长按输入框或者右键输入框时,是否弹出文本选择菜单。<br />默认值:false |
| barState<sup>10+</sup> | [BarState](ts-appendix-enums.md#BarState) | 设置内联输入风格编辑态时滚动条的显示模式。<br/>默认值:BarState.Auto | | barState<sup>10+</sup> | [BarState](ts-appendix-enums.md#BarState) | 设置内联输入风格编辑态时滚动条的显示模式。<br/>默认值:BarState.Auto |
| maxLines<sup>10+</sup> | number | 设置内联输入风格编辑态时文本可显示的最大行数。<br/>默认值:3 | | maxLines<sup>10+</sup> | number | 设置内联输入风格编辑态时文本可显示的最大行数。<br/>默认值:3 |
| customKeyboard<sup>10+</sup> | [CustomBuilder](ts-types.md#custombuilder8) | 设置自定义键盘。<br/>**说明:**<br/>当设置自定义键盘时,输入框激活后不会打开系统输入法,而是加载指定的自定义组件,针对系统键盘的enterKeyType属性设置将无效。<br/>自定义键盘的高度可以通过自定义组件根节点的height属性设置,宽度不可设置,使用系统默认值。<br/>自定义键盘采用覆盖原始界面的方式呈现,不会对应用原始界面产生压缩或者上提。<br/>自定义键盘无法获取焦点,但是会拦截手势事件。<br/>默认在输入控件失去焦点时,关闭自定义键盘,开发者也可以通过[TextInputController](#textinputcontroller8).[stopEditing](#stopediting10)方法控制键盘关闭。 | | customKeyboard<sup>10+</sup> | [CustomBuilder](ts-types.md#custombuilder8) | 设置自定义键盘。<br/>**说明:**<br/>当设置自定义键盘时,输入框激活后不会打开系统输入法,而是加载指定的自定义组件,针对系统键盘的enterKeyType属性设置将无效。<br/>自定义键盘的高度可以通过自定义组件根节点的height属性设置,宽度不可设置,使用系统默认值。<br/>自定义键盘采用覆盖原始界面的方式呈现,不会对应用原始界面产生压缩或者上提。<br/>自定义键盘无法获取焦点,但是会拦截手势事件。<br/>默认在输入控件失去焦点时,关闭自定义键盘,开发者也可以通过[TextInputController](#textinputcontroller8).[stopEditing](#stopediting10)方法控制键盘关闭。 |
> **说明:** > **说明:**
> >
...@@ -249,17 +249,20 @@ struct TextInputExample { ...@@ -249,17 +249,20 @@ struct TextInputExample {
### 示例2 ### 示例2
```ts ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct TextInputExample { struct TextInputExample {
@State PassWordSrc1:Resource=$r('app.media.icon') @State PassWordSrc1: Resource = $r('app.media.onIcon')
@State PassWordSrc2:Resource=$r('app.media.icon') @State PassWordSrc2: Resource = $r('app.media.offIcon')
@State TextError: string = undefined
@State Text: string = ''
@State NameText: string = 'test'
@Builder itemEnd() { @Builder itemEnd() {
Select([{ value: 'KB' }, Select([{ value: 'KB' },
{ value: 'MB' }, { value: 'MB' },
{ value: 'GB'}, { value: 'GB' },
{ value: 'TB',}]) { value: 'TB', }])
.height("48vp") .height("48vp")
.borderRadius(0) .borderRadius(0)
.selected(2) .selected(2)
...@@ -270,33 +273,52 @@ struct TextInputExample { ...@@ -270,33 +273,52 @@ struct TextInputExample {
.selectedOptionFont({ size: 20, weight: 400 }) .selectedOptionFont({ size: 20, weight: 400 })
.optionFont({ size: 20, weight: 400 }) .optionFont({ size: 20, weight: 400 })
.backgroundColor(Color.Transparent) .backgroundColor(Color.Transparent)
.responseRegion({height:"40vp",width:"80%",x:'10%',y:'6vp'}) .responseRegion({ height: "40vp", width: "80%", x: '10%', y: '6vp' })
.onSelect((index: number) => { .onSelect((index: number) => {
console.info('Select:' + index) console.info('Select:' + index)
}) })
} }
build() { build() {
Column() { Column({ space: 20 }) {
// 自定义密码显示图标 // 自定义密码显示图标
TextInput({ placeholder: 'user define password icon' }) TextInput({ placeholder: 'user define password icon' })
.type(InputType.Password) .type(InputType.Password)
.width(400) .width(380)
.height(60) .height(60)
.passwordIcon({onIconSrc:this.PassWordSrc1,offIconSrc : this.PassWordSrc2}) .passwordIcon({ onIconSrc: this.PassWordSrc1, offIconSrc: this.PassWordSrc2 })
// 下划线模式 // 下划线模式
TextInput({ placeholder: 'underline style' }) TextInput({ placeholder: 'underline style' })
.showUnderline(true) .showUnderline(true)
.width(400) .width(380)
.height(60) .height(60)
.showError('Error') .showError('Error')
.showUnit(this.itemEnd.bind(this)) .showUnit(this.itemEnd.bind(this))
Text(`用户名:${this.Text}`)
.width('95%')
TextInput({ placeholder: '请输入用户名', text: this.Text })
.showUnderline(true)
.width(380)
.showError(this.TextError)
.onChange((value: string) => {
this.Text = value
})
.onSubmit(() => { // 用户名不正确会清空输入框和用户名并提示错误文本
if (this.Text == this.NameText) {
this.TextError = undefined
} else {
this.TextError = '用户名输入错误'
this.Text = ''
}
})
}.width('100%') }.width('100%')
} }
} }
``` ```
![showUnit](figures/showUnit.png) ![TextInputError](figures/TextInputError.png)
### 示例3 ### 示例3
......
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
| ------ | ---------------------------------------- | ---- | ---------------------------------------- | | ------ | ---------------------------------------- | ---- | ---------------------------------------- |
| size | [Length](#length) | 否 | 设置文本尺寸,Length为number类型时,使用fp单位。不支持设置百分比字符串。<br>默认值:16.0 | | size | [Length](#length) | 否 | 设置文本尺寸,Length为number类型时,使用fp单位。不支持设置百分比字符串。<br>默认值:16.0 |
| weight | [FontWeight](ts-appendix-enums.md#fontweight) \| number \| string | 否 | 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,取值越大,字体越粗。<br>默认值:400 \| FontWeight.Normal | | weight | [FontWeight](ts-appendix-enums.md#fontweight) \| number \| string | 否 | 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,取值越大,字体越粗。<br>默认值:400 \| FontWeight.Normal |
| family | string \| [Resource](#resource) | 否 | 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效。例如:'Arial, HarmonyOS Sans'。当前只支持'HarmonyOS Sans'字体。 | | family | string \| [Resource](#resource) | 否 | 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效。例如:'Arial, HarmonyOS Sans'。当前支持'HarmonyOS Sans'字体和[注册自定义字体](../apis/js-apis-font.md)。 |
| style | [FontStyle](ts-appendix-enums.md#fontstyle) | 否 | 设置文本的字体样式。<br>默认值:FontStyle.Normal | | style | [FontStyle](ts-appendix-enums.md#fontstyle) | 否 | 设置文本的字体样式。<br>默认值:FontStyle.Normal |
## Area<sup>8+</sup> ## Area<sup>8+</sup>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
| fontSize | [Length](ts-types.md#length) | 设置字体大小,Length为number类型时,使用fp单位。字体默认大小16。不支持设置百分比字符串。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | fontSize | [Length](ts-types.md#length) | 设置字体大小,Length为number类型时,使用fp单位。字体默认大小16。不支持设置百分比字符串。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | 设置字体样式。<br>默认值:FontStyle.Normal<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | 设置字体样式。<br>默认值:FontStyle.Normal<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| fontWeight | number&nbsp;\|&nbsp;[FontWeight](ts-appendix-enums.md#fontweight)&nbsp;\|&nbsp;string | 设置文本的字体粗细,number类型取值[100,&nbsp;900],取值间隔为100,默认为400,取值越大,字体越粗。string类型仅支持number类型取值的字符串形式,例如"400",以及"bold"、"bolder"、"lighter"、"regular"、"medium",分别对应FontWeight中相应的枚举值。<br/>默认值:FontWeight.Normal<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | fontWeight | number&nbsp;\|&nbsp;[FontWeight](ts-appendix-enums.md#fontweight)&nbsp;\|&nbsp;string | 设置文本的字体粗细,number类型取值[100,&nbsp;900],取值间隔为100,默认为400,取值越大,字体越粗。string类型仅支持number类型取值的字符串形式,例如"400",以及"bold"、"bolder"、"lighter"、"regular"、"medium",分别对应FontWeight中相应的枚举值。<br/>默认值:FontWeight.Normal<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| fontFamily | string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 设置字体列表。默认字体'HarmonyOS Sans',且当前只支持这种字体<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | fontFamily | string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 设置字体列表。默认字体'HarmonyOS Sans',当前支持'HarmonyOS Sans'字体和[注册自定义字体](../apis/js-apis-font.md)<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| lineHeight | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | lineHeight | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| decoration | {<br/>type:&nbsp;[TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br/>color?:&nbsp;[ResourceColor](ts-types.md#resourcecolor)<br/>} | 设置文本装饰线样式及其颜色。<br />默认值:{<br/>type:&nbsp;TextDecorationType.None,<br/>color:Color.Black<br/>}<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | decoration | {<br/>type:&nbsp;[TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br/>color?:&nbsp;[ResourceColor](ts-types.md#resourcecolor)<br/>} | 设置文本装饰线样式及其颜色。<br />默认值:{<br/>type:&nbsp;TextDecorationType.None,<br/>color:Color.Black<br/>}<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
......
...@@ -546,7 +546,7 @@ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) { // 容器 ...@@ -546,7 +546,7 @@ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) { // 容器
```ts ```ts
Flex() { Flex() {
Text('flexGrow(1)') Text('flexGrow(1)')
.flexGrow(2) .flexGrow(1)
.width(100) .width(100)
.height(100) .height(100)
.backgroundColor(0xF5DEB3) .backgroundColor(0xF5DEB3)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册