在HarmonyOS NEXT开发中textInput .enabled(false) 设置false后, 自定义的passwordIcon 不生效?密码输入框,当enable设置为false时,自定的passwordIcon不生效。
TextInput({
text: 'this.mWifiPassword'
})
.type(InputType.Password)
.passwordIcon({ onIconSrc: $r("app.media.ic_open_eye"), offIconSrc: $r("app.media.ic_close_eye") })
.height(44)
.enabled(false)
解决方案
1.textInput组件的enabled属性设置为false意味着该组件不可交互,包括点击、按压、获取焦点等操作都将失效。
2.passwordIcon是textInput组件的一个属性,用于设置密码模式下输入框末尾的图标。
3.当textInput的enabled属性设置为false时,passwordIcon将无法响应任何点击或按压事件,因为组件本身已经失去了交互能力。
因此,设置textInput .enabled(false)后,自定义的passwordIcon将不再生效。如果需要确保passwordIcon在任何情况下都能正常工作,可以将textInput的enabled属性设置为true。