HarmonyOS TextInput如何开启禁止输入

HarmonyOS
2024-12-24 17:03:50
647浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
shlp

可以通过focusable属性来控制组件是否可以获焦来实现,焦点控制文档连接:

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-focus-V5#focusable

参考demo:

@Entry
@Component
struct TextInputExample {
  @State message: string = '0.3256'
  controller: TextInputController = new TextInputController()
  @State isOutinput: boolean = true
  @State isShow: boolean = false
  build() {
    Column(){
      TextInput({text: this.message})
        .focusable(this.isShow)
      Button("是否可输入").onClick(() =>{
        if(this.isOutinput){
          this.isShow = true
        }
      })
    }
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
分享
微博
QQ
微信
回复
2024-12-24 19:58:34
相关问题
TextInput如何禁止输入emoj表情
1413浏览 • 1回复 待解决
HarmonyOS TextInput支持禁止粘贴
662浏览 • 1回复 待解决
HarmonyOS TextInput如何换行输入
847浏览 • 1回复 待解决
HarmonyOS 如何TextInput获得输入焦点
832浏览 • 1回复 待解决
TextInput怎么输入中文
4015浏览 • 0回复 待解决
HarmonyOS textInput 如何清空输入
920浏览 • 2回复 待解决
HarmonyOS 如何获取TextInput输入的值
800浏览 • 1回复 待解决
HarmonyOS TextInput如何阻止其输入内容
1194浏览 • 1回复 待解决
HarmonyOS TextInput输入内容限制
1404浏览 • 1回复 待解决
HarmonyOS TextInput输入保留三位小数
800浏览 • 1回复 待解决