TextInput文本输入组件,用于接收用户输入的文本内容。
1、TextInput组件的参数
TextInput(value?:{placeholder?: string|Resource , text?: string|Resource})
- placeholder属性用于设置无输入时的提示文本
- text用于设置输入框当前的文本内容
@Entry
@Component
struct textInput {
@State isOn: boolean = true;
build() {
Column({ space: 10 }) {
Text('文本输入框 TextInput').fontSize(25)
TextInput({'placeholder':'输入文本内容','text':''}).width(200).height(50)
}
.width('100%')
.height("100%")
.justifyContent(FlexAlign.Center)
}
}
2、常用属性及事件
- 输入框类型
- 光标样式
- 文本样式
- change事件
- 焦点事件
2.1 输入框类型
可通过type()方法设置输入框的类型,该方法的参数为InputType枚举类型,可选的枚举值有