HarmonyOS 开发基础(四)TextIput
@Entry
@Component
struct Index {
build() {
Row() {
Column() {
// TextInput:ArkUI 的基础组件 单行文本输入框
// placeholder 参数,输入框无输入内容时的提示文本
// text:输入框当前的文本内容
TextInput({placeholder: "|请输入内容", text: "我是输入文本框"})
// width:属性方法,设置组件的宽度
.width(200)
// height:属性方法,设置组件的高度
.height(40)
// backgroundColor:属性方法,设置背景颜色
.backgroundColor('#aa7dfc')
// type:属性方法,设置文本框输入类型
.type(InputType.Number)
// onChange:组件事件,,当文本框输入内容时触发
.onChange(value => {
console.log(value)
})
}
}
}
}