本示例介绍如何使用Text组件实现验证码场景,并禁用对内容的选中、复制、光标。

使用说明
ForEach(this.codeIndexArray, (item: number, index: number) => {
Text(this.codeText[item])
.verifyCodeUnitStyle()
}, (item: number, index: number) => item.toString()) this.inputController.attach(true, textConfig); this.inputController.on("insertText", (text: string) => {
if (this.codeText.length >= this.verifyCodeLength) {
return;
}
this.codeText += text;
})
this.inputController.on("deleteLeft", (length: number) => {
this.codeText = this.codeText.substring(0, this.codeText.length - 1);
})鸿蒙开发各类文档,可关注公众号<程序猿百晓生>获取。1.OpenHarmony开发基础
2.OpenHarmony北向开发环境搭建
3.鸿蒙南向开发环境的搭建
4.鸿蒙生态应用开发白皮书V2.0 & V3.0
5.鸿蒙开发面试真题(含参考答案)
6.TypeScript入门学习手册
7.OpenHarmony 经典面试题(含参考答案)
8.OpenHarmony设备开发入门【最新版】
9.沉浸式剖析OpenHarmony源代码
10.系统定制指南
11.【OpenHarmony】Uboot 驱动加载流程
12.OpenHarmony构建系统--GN与子系统、部件、模块详解
13.ohos开机init启动流程
14.鸿蒙版性能优化指南
....... Flex(){
//...
}.onClick(() => {
this.attach();
}) .onVisibleAreaChange([0.0, 1, 0], async (isVisible: boolean, currentRatio: number) => {
if (isVisible && currentRatio >= 1.0) {
await this.attach();
this.listen();
}
if (!isVisible && currentRatio <= 0.0) {
this.dettach();
}
})不涉及
verifycode // har类型
|---constants
| |---VerifyCodeConstants.ets // 常量
|---view
| |---VerifyCodeView.ets // 视图层-验证码组件如果你觉得这篇内容对你还蛮有帮助,我想邀请你帮我三个小忙:
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。