目录

禁止编辑TextInput内容

问题现象

如何实现禁止编辑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);
  }
}