当focusOnTouch属性为true时,仅在组件可点击时才能正常获取焦点,更适合具有点击功能的组件,如TextInput。
@Entry @Component struct TextInputColorPage { message: string = 'Hello World'; build() { Column({ space: 16 }) { TextInput({ text: this.message }).enabled(false).fontColor(Color.Blue); TextInput({ text: this.message }).focusOnTouch(false).fontColor(Color.Gray); TextInput({ text: this.message }).focusable(false).fontColor(Color.Brown); } .padding(10); } }