在 OpenHarmony(ArkUI / eTS) 里,“验证码”通常不是系统控件,而是你自己用组件实现的。所以“换样式”本质是:改你写的验证码 UI 代码。下面按常见场景说明。
一般用:
Row + ForEachTextInput(隐藏输入)Text(显示数字)Row() {
ForEach(this.codeArray, (item, index) => {
Column() {
Text(item)
.fontSize(24)
.fontColor('#333')
Divider()
.width(30)
.height(2)
.color('#999')
}
.margin(10)
})
}
Text(item)
.fontSize(28)
.fontWeight(FontWeight.Bold)
.fontColor('#007DFF')
Column() {
Text(item)
.fontSize(24)
}
.width(40)
.height(48)
.border({ width: 1, color: '#007DFF' })
.borderRadius(8)
.border({
width: this.currentIndex === index ? 2 : 1,
color: this.currentIndex === index ? '#FF0000' : '#999'
})
下划线型
Divider()
.width(30)
.height(2)
方块型
.border({ width: 1, color: '#ccc' })
.borderRadius(6)
如果是后端返回的图片:
Image(this.captchaUrl)
.width(100)
.height(40)
.borderRadius(4)
换样式:
Image(this.captchaUrl)
.width(120)
.height(44)
.borderRadius(6)
.onClick(() => {
this.refreshCaptcha()
})
Button(this.countdown > 0 ? `${this.countdown}s` : '获取验证码')
.backgroundColor('#007DFF')
.fontColor('#fff')
.onClick(() => {
// 发送请求
})
CustomDialog 或 Component 封装验证码你可以直接贴一段你现在的验证码代码,我帮你改样式。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。