From 8e8e5a6f2547fb9cf5ead6bc53a7ed0622a5e289 Mon Sep 17 00:00:00 2001 From: Yao yuchi Date: Fri, 25 Feb 2022 13:45:52 +0800 Subject: [PATCH] modify pattern lock api docs Signed-off-by: Yao yuchi --- .../ts-basic-components-patternlock.md | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md index 22199f7261..4ba671745c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md @@ -37,6 +37,12 @@ PatternLock(controller?: PatternLockController) | pathStrokeWidth | Length | 34vp | 设置连线的宽度。最小可以设置为0。 | | autoReset | boolean | true | 设置是否支持用户在完成输入后再次触屏重置组件状态。如果设置为true,用户可以通过触摸图案密码锁重置组件状态(清除之前的输入效果);如果设置为false,用户手指离开屏幕完成输入后,再次触摸图案密码锁(包括圆点)不能改变之前的输入状态。 | +## 事件 + +| 名称 | 功能描述 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| onPatternComplete(callback: (input: Array\) => void) | 密码输入结束时被调用的回调函数。
input: 与选中宫格圆点顺序一致的数字数组,数字为选中宫格的索引(0到8)。 | + ## PatternLockController PatternLock组件的控制器,可以将此对象绑定至PatternLock组件,然后通过它进行状态重置。 @@ -53,12 +59,6 @@ reset():void 重置组件状态。 -## 事件 - -| 名称 | 功能描述 | -| -------------------------------------------------------- | ------------------------------------------------------------ | -| onPatternComplete(callback: (input: Array\) => void) | 密码输入结束时被调用的回调函数。
input: 与选中宫格圆点顺序一致的数字数组,数字为选中宫格的索引(0到8)。 | - ## 示例 ```typescript @@ -80,25 +80,25 @@ struct PatternLockExample { .autoReset(true) .onPatternComplete((input: Array) => { if (input == null || input == undefined || input.length < 5) { - this.message = 'The password length needs to be greater than 5.'; - return; + this.message = 'The password length needs to be greater than 5.' + return } if (this.passwords.length > 0) { if (this.passwords.toString() == input.toString()) { - this.passwords = input; - this.message = 'Set password successfully: ' + this.passwords.toString(); + this.passwords = input + this.message = 'Set password successfully: ' + this.passwords.toString() } else { - this.message = 'Inconsistent passwords, please enter again.'; + this.message = 'Inconsistent passwords, please enter again.' } } else { - this.passwords = input; - this.message = "Please enter again."; + this.passwords = input + this.message = "Please enter again." } }) Button('reset button').margin(30).onClick(() => { - this.patternLockController.reset(); - this.passwords = []; - this.message = 'Please input password'; + this.patternLockController.reset() + this.passwords = [] + this.message = 'Please input password' }) }.width('100%').height('100%') } -- GitLab