Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
8674f349
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8674f349
编写于
2月 18, 2022
作者:
Y
Yao yuchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pattern_lock api docs commit
Signed-off-by:
N
Yao yuchi
<
yaoyuchi@huawei.com
>
上级
1edd68f9
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
99 addition
and
0 deletion
+99
-0
zh-cn/application-dev/reference/arkui-ts/figures/patternlock.gif
...pplication-dev/reference/arkui-ts/figures/patternlock.gif
+0
-0
zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md
...dev/reference/arkui-ts/ts-basic-components-patternlock.md
+99
-0
未找到文件。
zh-cn/application-dev/reference/arkui-ts/figures/patternlock.gif
0 → 100644
浏览文件 @
8674f349
172.2 KB
zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md
0 → 100644
浏览文件 @
8674f349
# PatternLock<font color=ff0000><sup>8+</sup></font>
图案密码锁组件,以宫格图案的方式输入密码,用于密码验证。
## 子组件
无。
## 接口
PatternLock(controller?: PatternLockController)
-
参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---------- | --------------------- | ---- | ------ | -------------------------------------------- |
| controller | PatternLockController | 否 | null | 给组件绑定一个控制器,用来控制组件状态重置。 |
-
PatternLockController
PatternLock组件的控制器,可以将此对象绑定至PatternLock组件,然后通过它进行状态重置。
| 接口名称 | 功能描述 |
| ------------- | -------------- |
| reset():void; | 重置组件状态。 |
## 属性方法
不支持
*`backgroundColor`*
以外的通用属性设置。
| 名称 | 参数类型 | 默认值 | 描述 |
| --------------- | ---------------- | ----------- | ------------------------------------------------------------ |
| sideLength | Length | 300dp | 设置组件的宽度和高度(相同值)。最小可以设置为0。 |
| circleRadius | Length | 14dp | 设置宫格圆点的半径。 |
| backgroundColor | ResourceColor | 无 | 设置组件的背景色。 |
| regularColor | ResourceColor | Color.Black | 设置宫格圆点在“未选中”状态的填充颜色。 |
| selectedColor | ResourceColor | Color.Black | 设置宫格圆点在“选中”状态的填充颜色。 |
| activeColor | ResourceColor | Color.Black | 设置宫格圆点在“激活”状态的填充颜色。 |
| pathColor | ResourceColor | Color.Blue | 设置线段的颜色。 |
| pathStrokeWidth | number or string | 34dp | 设置连线的宽度。最小可以设置为0。 |
| autoReset | boolean | true | 设置是否支持用户在完成输入后再次触屏重置组件状态。如果设置为true,用户可以通过触摸图案密码锁重置组件状态(清除之前的输入效果);如果设置为false,用户手指离开屏幕完成输入后,再次触摸图案密码锁(包括圆点)不能改变之前的输入状态。 |
## 事件方法
| 事件名 | 参数类型 | 默认值 | 描述 |
| -------------------------------------------------------- | ------------- | ------ | ------------------------------------------------------------ |
| onPatternComplete | Array
<number>
| 无 | 指定输入状态结束时被调用的回调函数,参数是和输入顺序一致的数字数组。 |
## 示例
```
typescript
@
Entry
@
Component
struct
SwiperExample
{
@
State
passwords
:
Number
[]
=
[]
@
State
message
:
string
=
'
please input password
'
private
patternLockController
:
PatternLockController
=
new
PatternLockController
()
build
()
{
Flex
({
direction
:
FlexDirection
.
Column
,
alignItems
:
ItemAlign
.
Center
,
justifyContent
:
FlexAlign
.
Center
})
{
Text
(
this
.
message
).
textAlign
(
TextAlign
.
Center
)
PatternLock
(
this
.
patternLockController
)
.
sideLength
(
150
)
.
circleRadius
(
7
)
.
pathStrokeWidth
(
17
)
.
regularColor
(
Color
.
Black
)
.
selectedColor
(
Color
.
Black
)
.
activeColor
(
Color
.
Black
)
.
pathColor
(
Color
.
Blue
)
.
backgroundColor
(
Color
.
White
)
.
autoReset
(
true
)
.
onPatternComplete
((
input
:
Array
<
number
>
)
=>
{
if
(
input
==
null
||
input
==
undefined
||
input
.
length
<
5
)
{
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
();
}
else
{
this
.
message
=
'
Inconsistent passwords, please enter again.
'
;
}
}
else
{
this
.
passwords
=
input
;
this
.
message
=
"
Please enter again.
"
;
}
})
Button
(
'
reset button
'
).
margin
(
30
).
onClick
(()
=>
{
this
.
patternLockController
.
reset
();
this
.
passwords
=
[];
this
.
message
=
'
Please input password
'
;
})
}.
width
(
'
100%
'
).
height
(
'
100%
'
)
}
}
```

编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录