在 OpenHarmony(ArkUI)里,“验证码隐藏”通常指验证码输入框里的内容以圆点/星号显示,不显示明文。做法和普通的密码框一样,用 TextInput 的 type 和 showPassword 属性即可。
TextInput()
.type(InputType.Password) // 密码类型,自动隐藏
.maxLength(6)
.onChange((value) => {
// value 是真实验证码
})
@State isShow: boolean = false
TextInput()
.type(this.isShow ? InputType.Normal : InputType.Password)
.maxLength(6)
Button(this.isShow ? '隐藏' : '显示')
.onClick(() => {
this.isShow = !this.isShow
})
如果不想用系统密码框,也可以:
Text 显示 ••••••TextInput 接收输入示例:
TextInput()
.type(InputType.Password)
.caretColor(Color.Transparent)
OpenHarmony 隐藏验证码 = 使用 InputType.Password,如需切换显示就用状态变量控制 type。
如果你是:
可以告诉我,我给你对应写法。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。