Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
90b30801
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
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看板
未验证
提交
90b30801
编写于
8月 26, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 26, 2023
浏览文件
操作
浏览文件
下载
差异文件
!22875 Accessibility ArkTS规范整改
Merge pull request !22875 from zhanghuiyu/master
上级
558c8b13
67cf4c3a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
264 addition
and
166 deletion
+264
-166
zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePath.md
...n-dev/reference/apis/js-apis-accessibility-GesturePath.md
+2
-0
zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePoint.md
...-dev/reference/apis/js-apis-accessibility-GesturePoint.md
+2
-0
zh-cn/application-dev/reference/apis/js-apis-accessibility-config.md
...cation-dev/reference/apis/js-apis-accessibility-config.md
+51
-20
zh-cn/application-dev/reference/apis/js-apis-accessibility.md
...n/application-dev/reference/apis/js-apis-accessibility.md
+118
-64
zh-cn/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md
...apis/js-apis-application-accessibilityExtensionAbility.md
+19
-10
zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md
...s-apis-inner-application-accessibilityExtensionContext.md
+72
-72
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePath.md
浏览文件 @
90b30801
...
...
@@ -44,5 +44,7 @@ constructor(durationTime: number);
**示例:**
```
ts
import
GesturePath
from
'
@ohos.accessibility.GesturePath
'
;
let
gesturePath
=
new
GesturePath
.
GesturePath
(
20
);
```
zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePoint.md
浏览文件 @
90b30801
...
...
@@ -45,5 +45,7 @@ constructor(positionX: number, positionY: number);
**示例:**
```
ts
import
GesturePoint
from
'
@ohos.accessibility.GesturePoint
'
;
let
gesturePoint
=
new
GesturePoint
.
GesturePoint
(
1
,
2
);
```
zh-cn/application-dev/reference/apis/js-apis-accessibility-config.md
浏览文件 @
90b30801
...
...
@@ -68,12 +68,14 @@ enableAbility(name: string, capability: Array<accessibility.Capability>):
```
ts
import
accessibility
from
'
@ohos.accessibility
'
;
let
name
=
'
com.ohos.example/axExtension
'
;
import
config
from
'
@ohos.accessibility.config
'
;
let
name
:
string
=
'
com.ohos.example/axExtension
'
;
let
capability
:
accessibility
.
Capability
[]
=
[
'
retrieve
'
];
try
{
config
.
enableAbility
(
name
,
capability
).
then
(()
=>
{
console
.
info
(
'
enable ability succeed
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
'
failed to enable ability, because
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
...
...
@@ -110,10 +112,13 @@ enableAbility(name: string, capability: Array<accessibility.Capability>, c
```
ts
import
accessibility
from
'
@ohos.accessibility
'
;
let
name
=
'
com.ohos.example/axExtension
'
;
let
capability
:
accessibility
.
Capability
[]
=
[
'
retrieve
'
];
import
config
from
'
@ohos.accessibility.config
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
name
:
string
=
'
com.ohos.example/axExtension
'
;
let
capability
:
accessibility
.
Capability
[]
=
[
'
retrieve
'
];
try
{
config
.
enableAbility
(
name
,
capability
,
(
err
)
=>
{
config
.
enableAbility
(
name
,
capability
,
(
err
:
BusinessError
<
void
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to enable ability, because
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -156,11 +161,14 @@ disableAbility(name: string): Promise<void>;
**示例:**
```
ts
let
name
=
'
com.ohos.example/axExtension
'
;
import
accessibility
from
'
@ohos.accessibility
'
;
import
config
from
'
@ohos.accessibility.config
'
;
let
name
:
string
=
'
com.ohos.example/axExtension
'
;
try
{
config
.
disableAbility
(
name
).
then
(()
=>
{
console
.
info
(
'
disable ability succeed
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
'
failed to disable ability, because
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
...
...
@@ -194,9 +202,13 @@ disableAbility(name: string, callback: AsyncCallback<void>): void;
**示例:**
```
ts
let
name
=
'
com.ohos.example/axExtension
'
;
import
accessibility
from
'
@ohos.accessibility
'
;
import
config
from
'
@ohos.accessibility.config
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
name
:
string
=
'
com.ohos.example/axExtension
'
;
try
{
config
.
disableAbility
(
name
,
(
err
,
data
)
=>
{
config
.
disableAbility
(
name
,
(
err
:
BusinessError
<
void
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to enable ability, because
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -226,6 +238,8 @@ on(type: 'enabledAccessibilityExtensionListChange', callback: Callback<void&g
**示例:**
```
ts
import
config
from
'
@ohos.accessibility.config
'
;
try
{
config
.
on
(
'
enabledAccessibilityExtensionListChange
'
,
()
=>
{
console
.
info
(
'
subscribe enabled accessibility extension list change state success
'
);
...
...
@@ -254,6 +268,8 @@ off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback<void
**示例:**
```
ts
import
config
from
'
@ohos.accessibility.config
'
;
try
{
config
.
off
(
'
enabledAccessibilityExtensionListChange
'
,
()
=>
{
console
.
info
(
'
Unsubscribe enabled accessibility extension list change state success
'
);
...
...
@@ -291,11 +307,13 @@ set(value: T): Promise<void>;
**示例:**
```
ts
let
value
=
true
;
import
config
from
'
@ohos.accessibility.config
'
;
let
value
:
boolean
=
true
;
try
{
config
.
highContrastText
.
set
(
value
).
then
(()
=>
{
console
.
info
(
'
set highContrastText succeed
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
'
failed to set highContrastText, because
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
...
...
@@ -321,9 +339,12 @@ set(value: T, callback: AsyncCallback<void>): void;
**示例:**
```
ts
let
value
=
true
;
import
config
from
'
@ohos.accessibility.config
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
value
:
boolean
=
true
;
try
{
config
.
highContrastText
.
set
(
value
,
(
err
,
data
)
=>
{
config
.
highContrastText
.
set
(
value
,
(
err
:
BusinessError
<
void
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to set highContrastText, because
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -352,11 +373,14 @@ get(): Promise<T>;
**示例:**
```
ts
let
value
;
config
.
highContrastText
.
get
().
then
((
data
)
=>
{
import
config
from
'
@ohos.accessibility.config
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
value
:
boolean
;
config
.
highContrastText
.
get
().
then
((
data
:
boolean
)
=>
{
value
=
data
;
console
.
info
(
'
get highContrastText success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
'
failed to get highContrastText, because
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -378,8 +402,11 @@ get(callback: AsyncCallback<T>): void;
**示例:**
```
ts
let
value
;
config
.
highContrastText
.
get
((
err
,
data
)
=>
{
import
config
from
'
@ohos.accessibility.config
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
value
:
boolean
;
config
.
highContrastText
.
get
((
err
:
BusinessError
<
void
>
,
data
:
boolean
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get highContrastText, because
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -406,8 +433,10 @@ on(callback: Callback<T>): void;
**示例:**
```
ts
import
config
from
'
@ohos.accessibility.config
'
;
try
{
config
.
highContrastText
.
on
((
data
)
=>
{
config
.
highContrastText
.
on
((
data
:
boolean
)
=>
{
console
.
info
(
'
subscribe highContrastText success, result:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
exception
)
{
...
...
@@ -432,7 +461,9 @@ off(callback?: Callback<T>): void;
**示例:**
```
ts
config
.
highContrastText
.
off
((
data
)
=>
{
import
config
from
'
@ohos.accessibility.config
'
;
config
.
highContrastText
.
off
((
data
:
boolean
)
=>
{
console
.
info
(
'
Unsubscribe highContrastText success, result:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-accessibility.md
浏览文件 @
90b30801
...
...
@@ -174,9 +174,11 @@ on(type: 'enableChange', callback: Callback<boolean>): void;
**示例:**
```
ts
import
accessibility
from
'
@ohos.accessibility
'
;
let
captionsManager
=
accessibility
.
getCaptionsManager
();
try
{
captionsManager
.
on
(
'
enableChange
'
,
(
data
)
=>
{
captionsManager
.
on
(
'
enableChange
'
,
(
data
:
boolean
)
=>
{
console
.
info
(
'
subscribe caption manager enable state change, result:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
exception
)
{
...
...
@@ -202,10 +204,12 @@ on(type: 'styleChange', callback: Callback<CaptionsStyle>): void;
**示例:**
```
ts
let
captionStyle
;
import
accessibility
from
'
@ohos.accessibility
'
;
let
captionStyle
:
accessibility
.
CaptionsStyle
;
let
captionsManager
=
accessibility
.
getCaptionsManager
();
try
{
captionsManager
.
on
(
'
styleChange
'
,
(
data
)
=>
{
captionsManager
.
on
(
'
styleChange
'
,
(
data
:
accessibility
.
CaptionsStyle
)
=>
{
captionStyle
=
data
;
console
.
info
(
'
subscribe caption manager style state change, result:
'
+
JSON
.
stringify
(
data
));
});
...
...
@@ -232,9 +236,11 @@ off(type: 'enableChange', callback?: Callback<boolean>): void;
**示例:**
```
ts
import
accessibility
from
'
@ohos.accessibility
'
;
let
captionsManager
=
accessibility
.
getCaptionsManager
();
try
{
captionsManager
.
off
(
'
enableChange
'
,
(
data
)
=>
{
captionsManager
.
off
(
'
enableChange
'
,
(
data
:
boolean
)
=>
{
console
.
info
(
'
Unsubscribe caption manager enable state change, result:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
exception
)
{
...
...
@@ -260,10 +266,12 @@ off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void;
**示例:**
```
ts
let
captionStyle
;
import
accessibility
from
'
@ohos.accessibility
'
;
let
captionStyle
:
accessibility
.
CaptionsStyle
;
let
captionsManager
=
accessibility
.
getCaptionsManager
();
try
{
captionsManager
.
off
(
'
styleChange
'
,
(
data
)
=>
{
captionsManager
.
off
(
'
styleChange
'
,
(
data
:
accessibility
.
CaptionsStyle
)
=>
{
captionStyle
=
data
;
console
.
info
(
'
Unsubscribe caption manager style state change, result:
'
+
JSON
.
stringify
(
data
));
});
...
...
@@ -314,10 +322,12 @@ constructor(jsonObject)
**示例:**
```
ts
let
eventInfo
=
new
accessibility
.
EventInfo
({
'
type
'
:
'
click
'
,
'
bundleName
'
:
'
com.example.MyApplication
'
,
'
triggerAction
'
:
'
click
'
import
accessibility
from
'
@ohos.accessibility
'
;
let
eventInfo
:
accessibility
.
EventInfo
=
({
type
:
'
click
'
,
bundleName
:
'
com.example.MyApplication
'
,
triggerAction
:
'
click
'
});
```
...
...
@@ -398,24 +408,28 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise<A
**示例:**
```
ts
let
abilityType
=
'
spoken
'
;
let
abilityState
=
'
enable
'
;
let
abilityList
:
accessibility
.
AccessibilityInfo
[];
import
accessibility
from
'
@ohos.accessibility
'
;
let
abilityType
:
accessibility
.
AbilityType
=
'
spoken
'
;
let
abilityState
:
accessibility
.
AbilityState
=
'
enable
'
;
let
abilityList
:
accessibility
.
AccessibilityAbilityInfo
[];
try
{
accessibility
.
getAbilityLists
(
abilityType
,
abilityState
).
then
((
data
)
=>
{
for
(
let
item
of
data
)
{
console
.
info
(
item
.
id
);
console
.
info
(
item
.
name
);
console
.
info
(
item
.
description
);
console
.
info
(
item
.
bundleName
);
extensionList
.
push
(
item
);
}
console
.
info
(
'
get accessibility extension list success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get accessibility extension list because
'
+
JSON
.
stringify
(
err
));
accessibility
.
getAbilityLists
(
abilityType
,
abilityState
)
.
then
((
data
:
accessibility
.
AccessibilityAbilityInfo
[])
=>
{
for
(
let
item
of
data
)
{
console
.
info
(
item
.
id
);
console
.
info
(
item
.
name
);
console
.
info
(
item
.
description
);
console
.
info
(
item
.
bundleName
);
abilityList
.
push
(
item
);
}
console
.
info
(
'
get accessibility extension list success
'
);
})
.
catch
((
err
:
object
)
=>
{
console
.
error
(
'
failed to get accessibility extension list because
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get accessibility extension list because
'
+
JSON
.
stringify
(
exception
));
console
.
error
(
'
failed to get accessibility extension list because
'
+
JSON
.
stringify
(
exception
));
}
```
...
...
@@ -443,11 +457,15 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: Asyn
**示例:**
```
ts
let
abilityType
=
'
spoken
'
;
let
abilityState
=
'
enable
'
;
import
accessibility
from
'
@ohos.accessibility
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
abilityType
:
accessibility
.
AbilityType
=
'
spoken
'
;
let
abilityState
:
accessibility
.
AbilityState
=
'
enable
'
;
let
abilityList
:
accessibility
.
AccessibilityInfo
[];
try
{
accessibility
.
getAbilityLists
(
abilityType
,
abilityState
,
(
err
,
data
)
=>
{
accessibility
.
getAbilityLists
(
abilityType
,
abilityState
,
(
err
:
BusinessError
<
void
>
,
data
:
accessibility
.
AccessibilityAbilityInfo
[])
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get accessibility extension list because
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -460,9 +478,7 @@ try {
abilityList
.
push
(
item
);
}
console
.
info
(
'
get accessibility extension list success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get accessibility extension list because
'
+
JSON
.
stringify
(
err
));
});
})
}
catch
(
exception
)
{
console
.
error
(
'
failed to get accessibility extension list because
'
+
JSON
.
stringify
(
exception
));
}
...
...
@@ -492,11 +508,14 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState)
**示例:**
```
ts
import
accessibility
from
'
@ohos.accessibility
'
;
let
abilityType
:
accessibility
.
AbilityType
=
'
spoken
'
;
let
abilityState
:
accessibility
.
AbilityState
=
'
enable
'
;
let
extensionList
:
accessibility
.
AccessibilityAbilityInfo
[]
=
[];
try
{
accessibility
.
getAccessibilityExtensionList
(
abilityType
,
abilityState
).
then
((
data
)
=>
{
accessibility
.
getAccessibilityExtensionList
(
abilityType
,
abilityState
)
.
then
((
data
:
accessibility
.
AccessibilityAbilityInfo
[])
=>
{
for
(
let
item
of
data
)
{
console
.
info
(
item
.
id
);
console
.
info
(
item
.
name
);
...
...
@@ -505,7 +524,8 @@ try {
extensionList
.
push
(
item
);
}
console
.
info
(
'
get accessibility extension list success
'
);
}).
catch
((
err
)
=>
{
})
.
catch
((
err
:
object
)
=>
{
console
.
error
(
'
failed to get accessibility extension list because
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
...
...
@@ -532,11 +552,15 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState,
**示例:**
```
ts
import
accessibility
from
'
@ohos.accessibility
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
abilityType
:
accessibility
.
AbilityType
=
'
spoken
'
;
let
abilityState
:
accessibility
.
AbilityState
=
'
enable
'
;
let
extensionList
:
accessibility
.
AccessibilityAbilityInfo
[]
=
[];
try
{
accessibility
.
getAccessibilityExtensionList
(
abilityType
,
abilityState
,
(
err
,
data
)
=>
{
accessibility
.
getAccessibilityExtensionList
(
abilityType
,
abilityState
,
(
err
:
BusinessError
<
void
>
,
data
:
accessibility
.
AccessibilityAbilityInfo
[])
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get accessibility extension list because
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -572,6 +596,8 @@ getCaptionsManager(): CaptionsManager
**示例:**
```
ts
import
accessibility
from
'
@ohos.accessibility
'
;
let
captionsManager
=
accessibility
.
getCaptionsManager
();
```
...
...
@@ -593,8 +619,10 @@ on(type: 'accessibilityStateChange', callback: Callback<boolean>): void
**示例:**
```
ts
import
accessibility
from
'
@ohos.accessibility
'
;
try
{
accessibility
.
on
(
'
accessibilityStateChange
'
,
(
data
)
=>
{
accessibility
.
on
(
'
accessibilityStateChange
'
,
(
data
:
boolean
)
=>
{
console
.
info
(
'
subscribe accessibility state change, result:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
exception
)
{
...
...
@@ -620,8 +648,10 @@ on(type: 'touchGuideStateChange', callback: Callback<boolean>): void
**示例:**
```
ts
import
accessibility
from
'
@ohos.accessibility
'
;
try
{
accessibility
.
on
(
'
touchGuideStateChange
'
,
(
data
)
=>
{
accessibility
.
on
(
'
touchGuideStateChange
'
,
(
data
:
boolean
)
=>
{
console
.
info
(
'
subscribe touch guide state change, result:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
exception
)
{
...
...
@@ -647,8 +677,10 @@ off(type: 'accessibilityStateChange', callback?: Callback<boolean>): void
**示例:**
```
ts
import
accessibility
from
'
@ohos.accessibility
'
;
try
{
accessibility
.
off
(
'
accessibilityStateChange
'
,
(
data
)
=>
{
accessibility
.
off
(
'
accessibilityStateChange
'
,
(
data
:
boolean
)
=>
{
console
.
info
(
'
Unsubscribe accessibility state change, result:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
exception
)
{
...
...
@@ -674,8 +706,10 @@ off(type: 'touchGuideStateChange', callback?: Callback<boolean>): void
**示例:**
```
ts
import
accessibility
from
'
@ohos.accessibility
'
;
try
{
accessibility
.
off
(
'
touchGuideStateChange
'
,
(
data
)
=>
{
accessibility
.
off
(
'
touchGuideStateChange
'
,
(
data
:
boolean
)
=>
{
console
.
info
(
'
Unsubscribe touch guide state change, result:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
exception
)
{
...
...
@@ -700,9 +734,11 @@ isOpenAccessibility(): Promise<boolean>
**示例:**
```
ts
accessibility
.
isOpenAccessibility
().
then
((
data
)
=>
{
import
accessibility
from
'
@ohos.accessibility
'
;
accessibility
.
isOpenAccessibility
().
then
((
data
:
boolean
)
=>
{
console
.
info
(
'
success data:isOpenAccessibility :
'
+
JSON
.
stringify
(
data
))
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
'
failed to isOpenAccessibility because
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -724,7 +760,10 @@ isOpenAccessibility(callback: AsyncCallback<boolean>): void
**示例:**
```
ts
accessibility
.
isOpenAccessibility
((
err
,
data
)
=>
{
import
accessibility
from
'
@ohos.accessibility
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
accessibility
.
isOpenAccessibility
((
err
:
BusinessError
<
void
>
,
data
:
boolean
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to isOpenAccessibility because
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -750,9 +789,11 @@ isOpenTouchGuide(): Promise<boolean>
**示例:**
```
ts
accessibility
.
isOpenTouchGuide
().
then
((
data
)
=>
{
import
accessibility
from
'
@ohos.accessibility
'
;
accessibility
.
isOpenTouchGuide
().
then
((
data
:
boolean
)
=>
{
console
.
info
(
'
success data:isOpenTouchGuide :
'
+
JSON
.
stringify
(
data
))
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
'
failed to isOpenTouchGuide because
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -774,7 +815,10 @@ isOpenTouchGuide(callback: AsyncCallback<boolean>): void
**示例:**
```
ts
accessibility
.
isOpenTouchGuide
((
err
,
data
)
=>
{
import
accessibility
from
'
@ohos.accessibility
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
accessibility
.
isOpenTouchGuide
((
err
:
BusinessError
<
void
>
,
data
:
boolean
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to isOpenTouchGuide because
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -811,14 +855,16 @@ sendEvent(event: EventInfo): Promise<void>
**示例:**
```
ts
let
eventInfo
=
new
accessibility
.
EventInfo
({
'
type
'
:
'
click
'
,
'
bundleName
'
:
'
com.example.MyApplication
'
,
'
triggerAction
'
:
'
click
'
import
accessibility
from
'
@ohos.accessibility
'
;
let
eventInfo
:
accessibility
.
EventInfo
=
({
type
:
'
click
'
,
bundleName
:
'
com.example.MyApplication
'
,
triggerAction
:
'
click
'
});
accessibility
.
sendEvent
(
eventInfo
).
then
(()
=>
{
console
.
info
(
'
send event success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
'
failed to sendEvent because
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -846,12 +892,15 @@ sendEvent(event: EventInfo, callback: AsyncCallback<void>): void
**示例:**
```
ts
let
eventInfo
=
new
accessibility
.
EventInfo
({
'
type
'
:
'
click
'
,
'
bundleName
'
:
'
com.example.MyApplication
'
,
'
triggerAction
'
:
'
click
'
import
accessibility
from
'
@ohos.accessibility
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
eventInfo
:
accessibility
.
EventInfo
=
({
type
:
'
click
'
,
bundleName
:
'
com.example.MyApplication
'
,
triggerAction
:
'
click
'
});
accessibility
.
sendEvent
(
eventInfo
,
(
err
,
data
)
=>
{
accessibility
.
sendEvent
(
eventInfo
,
(
err
:
BusinessError
<
void
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to sendEvent because
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -883,15 +932,17 @@ sendAccessibilityEvent(event: EventInfo): Promise<void>
**示例:**
```
ts
let
eventInfo
=
new
accessibility
.
EventInfo
({
'
type
'
:
'
click
'
,
'
bundleName
'
:
'
com.example.MyApplication
'
,
'
triggerAction
'
:
'
click
'
import
accessibility
from
'
@ohos.accessibility
'
;
let
eventInfo
:
accessibility
.
EventInfo
=
({
type
:
'
click
'
,
bundleName
:
'
com.example.MyApplication
'
,
triggerAction
:
'
click
'
});
try
{
accessibility
.
sendAccessibilityEvent
(
eventInfo
).
then
(()
=>
{
console
.
info
(
'
send event success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
'
failed to send event because
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
...
...
@@ -917,13 +968,16 @@ sendAccessibilityEvent(event: EventInfo, callback: AsyncCallback<void>): v
**示例:**
```
ts
let
eventInfo
=
new
accessibility
.
EventInfo
({
'
type
'
:
'
click
'
,
'
bundleName
'
:
'
com.example.MyApplication
'
,
'
triggerAction
'
:
'
click
'
import
accessibility
from
'
@ohos.accessibility
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
eventInfo
:
accessibility
.
EventInfo
=
({
type
:
'
click
'
,
bundleName
:
'
com.example.MyApplication
'
,
triggerAction
:
'
click
'
});
try
{
accessibility
.
sendEvent
(
eventInfo
,
(
err
,
data
)
=>
{
accessibility
.
sendEvent
(
eventInfo
,
(
err
:
BusinessError
<
void
>
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to send event because
'
+
JSON
.
stringify
(
err
));
return
;
...
...
zh-cn/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md
浏览文件 @
90b30801
...
...
@@ -92,11 +92,13 @@ onConnect(): void;
**示例:**
```
ts
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
;
class
MyAccessibilityExtensionAbility
extends
AccessibilityExtensionAbility
{
onConnect
()
{
onConnect
()
:
void
{
console
.
log
(
'
AxExtensionAbility onConnect
'
);
}
}
;
}
```
## AccessibilityExtensionAbility.onDisconnect
...
...
@@ -110,11 +112,13 @@ onDisconnect(): void;
**示例:**
```
ts
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
;
class
MyAccessibilityExtensionAbility
extends
AccessibilityExtensionAbility
{
onDisconnect
()
{
onDisconnect
()
:
void
{
console
.
log
(
'
AxExtensionAbility onDisconnect
'
);
}
}
;
}
```
## AccessibilityExtensionAbility.onAccessibilityEvent
...
...
@@ -134,14 +138,16 @@ onAccessibilityEvent(event: AccessibilityEvent): void;
**示例:**
```
ts
import
AccessibilityExtensionAbility
,
{
AccessibilityEvent
}
from
'
@ohos.application.AccessibilityExtensionAbility
'
;
class
MyAccessibilityExtensionAbility
extends
AccessibilityExtensionAbility
{
onAccessibilityEvent
(
event
)
{
onAccessibilityEvent
(
event
:
AccessibilityEvent
):
void
{
console
.
log
(
'
AxExtensionAbility onAccessibilityEvent
'
);
if
(
event
.
eventType
===
'
click
'
)
{
console
.
log
(
'
AxExtensionAbility onAccessibilityEvent: click
'
);
}
}
}
;
}
```
## AccessibilityExtensionAbility.onKeyEvent
...
...
@@ -161,14 +167,17 @@ onKeyEvent(keyEvent: KeyEvent): boolean;
**示例:**
```
ts
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
;
import
{
KeyEvent
}
from
'
@ohos.multimodalInput.keyEvent
'
;
class
MyAccessibilityExtensionAbility
extends
AccessibilityExtensionAbility
{
onKeyEvent
(
keyEvent
)
{
onKeyEvent
(
keyEvent
:
KeyEvent
):
boolean
{
console
.
log
(
'
AxExtensionAbility onKeyEvent
'
);
if
(
keyEvent
.
key
Code
===
22
)
{
console
.
log
(
'
AxExtensionAbility onKeyEvent: intercept
22
'
);
if
(
keyEvent
.
key
.
code
===
16
)
{
console
.
log
(
'
AxExtensionAbility onKeyEvent: intercept
16
'
);
return
true
;
}
return
false
;
}
}
;
}
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md
浏览文件 @
90b30801
...
...
@@ -102,11 +102,11 @@ let targetNames = ['com.ohos.xyz'];
try
{
axContext
.
setTargetBundleName
(
targetNames
).
then
(()
=>
{
console
.
info
(
'
set target bundle names success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to set target bundle names, because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
`failed to set target bundle names, because
${
JSON
.
stringify
(
err
)}
`
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to set target bundle names, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to set target bundle names, because
${
JSON
.
stringify
(
exception
)}
`
);
};
```
...
...
@@ -131,14 +131,14 @@ setTargetBundleName(targetNames: Array\<string>, callback: AsyncCallback\<void>)
let
targetNames
=
[
'
com.ohos.xyz
'
];
try
{
axContext
.
setTargetBundleName
(
targetNames
,
(
err
,
data
)
=>
{
if
(
err
&&
err
.
code
)
{
console
.
error
(
'
failed to set target bundle names, because ${JSON.stringify(err)}
'
);
if
(
err
)
{
console
.
error
(
`failed to set target bundle names, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
info
(
'
set target bundle names success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to set target bundle names, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to set target bundle names, because
${
JSON
.
stringify
(
exception
)}
`
);
};
```
...
...
@@ -178,11 +178,11 @@ try {
axContext
.
getFocusElement
().
then
((
data
)
=>
{
focusElement
=
data
;
console
.
log
(
'
get focus element success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get focus element, because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
`failed to get focus element, because
${
JSON
.
stringify
(
err
)}
`
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get focus element, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to get focus element, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
...
...
@@ -214,15 +214,15 @@ getFocusElement(callback: AsyncCallback\<AccessibilityElement>): void;
let
focusElement
;
try
{
axContext
.
getFocusElement
((
err
,
data
)
=>
{
if
(
err
&&
err
.
code
)
{
console
.
error
(
'
failed to get focus element, because ${JSON.stringify(err)}
'
);
if
(
err
)
{
console
.
error
(
`failed to get focus element, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
focusElement
=
data
;
console
.
info
(
'
get focus element success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get focus element, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to get focus element, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
...
...
@@ -256,15 +256,15 @@ let focusElement;
let
isAccessibilityFocus
=
true
;
try
{
axContext
.
getFocusElement
(
isAccessibilityFocus
,
(
err
,
data
)
=>
{
if
(
err
&&
err
.
code
)
{
console
.
error
(
'
failed to get focus element, because ${JSON.stringify(err)}
'
);
if
(
err
)
{
console
.
error
(
`failed to get focus element, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
focusElement
=
data
;
console
.
info
(
'
get focus element success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get focus element, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to get focus element, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
## AccessibilityExtensionContext.getWindowRootElement
...
...
@@ -303,11 +303,11 @@ try {
axContext
.
getWindowRootElement
().
then
((
data
)
=>
{
rootElement
=
data
;
console
.
log
(
'
get root element of the window success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get root element of the window, because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
`failed to get root element of the window, because
${
JSON
.
stringify
(
err
)}
`
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get root element of the window, ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to get root element of the window,
${
JSON
.
stringify
(
exception
)}
`
);
}
```
...
...
@@ -339,15 +339,15 @@ getWindowRootElement(callback: AsyncCallback\<AccessibilityElement>): void;
let
rootElement
;
try
{
axContext
.
getWindowRootElement
((
err
,
data
)
=>
{
if
(
err
&&
err
.
code
)
{
console
.
error
(
'
failed to get root element of the window, because ${JSON.stringify(err)}
'
);
if
(
err
)
{
console
.
error
(
`failed to get root element of the window, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
rootElement
=
data
;
console
.
info
(
'
get root element of the window success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get root element of the window, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to get root element of the window, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
...
...
@@ -381,15 +381,15 @@ let rootElement;
let
windowId
=
10
;
try
{
axContext
.
getWindowRootElement
(
windowId
,
(
err
,
data
)
=>
{
if
(
err
&&
err
.
code
)
{
console
.
error
(
'
failed to get root element of the window, because ${JSON.stringify(err)}
'
);
if
(
err
)
{
console
.
error
(
`failed to get root element of the window, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
rootElement
=
data
;
console
.
info
(
'
get root element of the window success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get root element of the window, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to get root element of the window, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
...
...
@@ -429,11 +429,11 @@ try {
axContext
.
getWindows
().
then
((
data
)
=>
{
windows
=
data
;
console
.
log
(
'
get windows success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get windows, because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
`failed to get windows, because
${
JSON
.
stringify
(
err
)}
`
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get windows, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to get windows, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
...
...
@@ -465,15 +465,15 @@ getWindows(callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
let
windows
;
try
{
axContext
.
getWindows
((
err
,
data
)
=>
{
if
(
err
&&
err
.
code
)
{
console
.
error
(
'
failed to get windows, because ${JSON.stringify(err)}
'
);
if
(
err
)
{
console
.
error
(
`failed to get windows, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
windows
=
data
;
console
.
info
(
'
get windows success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get windows, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to get windows, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
...
...
@@ -507,15 +507,15 @@ let windows;
let
displayId
=
10
;
try
{
axContext
.
getWindows
(
displayId
,
(
err
,
data
)
=>
{
if
(
err
&&
err
.
code
)
{
console
.
error
(
'
failed to get windows, because ${JSON.stringify(err)}
'
);
if
(
err
)
{
console
.
error
(
`failed to get windows, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
windows
=
data
;
console
.
info
(
'
get windows success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get windows, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to get windows, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
...
...
@@ -560,11 +560,11 @@ try {
}
axContext
.
injectGesture
(
gesturePath
).
then
(()
=>
{
console
.
info
(
'
inject gesture success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to inject gesture, because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
`failed to inject gesture, because
${
JSON
.
stringify
(
err
)}
`
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to inject gesture, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to inject gesture, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
## AccessibilityExtensionContext.injectGesture
...
...
@@ -602,14 +602,14 @@ try {
gesturePath
.
points
.
push
(
gesturePoint
);
}
axContext
.
injectGesture
(
gesturePath
,
(
err
,
data
)
=>
{
if
(
err
&&
err
.
code
)
{
console
.
error
(
'
failed to inject gesture, because ${JSON.stringify(err)}
'
);
if
(
err
)
{
console
.
error
(
`failed to inject gesture, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
info
(
'
inject gesture success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to inject gesture, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to inject gesture, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
## AccessibilityElement<sup>9+</sup>
...
...
@@ -639,8 +639,8 @@ let attributeNames;
rootElement
.
attributeNames
().
then
((
data
)
=>
{
console
.
log
(
'
get attribute names success
'
);
attributeNames
=
data
;
}).
catch
((
err
)
=>
{
console
.
log
(
'
failed to get attribute names, because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
log
(
`failed to get attribute names, because
${
JSON
.
stringify
(
err
)}
`
);
});
```
### attributeNames
...
...
@@ -663,7 +663,7 @@ attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\
let
attributeNames
;
rootElement
.
attributeNames
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get attribute names, because ${JSON.stringify(err)}
'
);
console
.
error
(
`failed to get attribute names, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
attributeNames
=
data
;
...
...
@@ -707,11 +707,11 @@ try {
rootElement
.
attributeValue
(
attributeName
).
then
((
data
)
=>
{
console
.
log
(
'
get attribute value by name success
'
);
attributeValue
=
data
;
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get attribute value, because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
`failed to get attribute value, because
${
JSON
.
stringify
(
err
)}
`
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get attribute value, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to get attribute value, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
### attributeValue
...
...
@@ -746,14 +746,14 @@ let attributeName = 'name';
try
{
rootElement
.
attributeValue
(
attributeName
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get attribute value, because ${JSON.stringify(err)}
'
);
console
.
error
(
`failed to get attribute value, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
attributeValue
=
data
;
console
.
info
(
'
get attribute value success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to get attribute value, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to get attribute value, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
### actionNames
...
...
@@ -777,8 +777,8 @@ let actionNames;
rootElement
.
actionNames
().
then
((
data
)
=>
{
console
.
log
(
'
get action names success
'
);
actionNames
=
data
;
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to get action names because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
`failed to get action names because
${
JSON
.
stringify
(
err
)}
`
);
});
```
### actionNames
...
...
@@ -801,7 +801,7 @@ actionNames(callback: AsyncCallback\<Array\<string>>): void;
let
actionNames
;
rootElement
.
actionNames
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to get action names, because ${JSON.stringify(err)}
'
);
console
.
error
(
`failed to get action names, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
actionNames
=
data
;
...
...
@@ -843,11 +843,11 @@ performAction(actionName: string, parameters?: object): Promise\<void>;
try
{
rootElement
.
performAction
(
'
action
'
).
then
((
data
)
=>
{
console
.
info
(
'
perform action success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to perform action, because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
`failed to perform action, because
${
JSON
.
stringify
(
err
)}
`
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to perform action, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to perform action, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
### performAction
...
...
@@ -879,13 +879,13 @@ performAction(actionName: string, callback: AsyncCallback\<void>): void;
try
{
rootElement
.
performAction
(
'
action
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to perform action, because ${JSON.stringify(err)}
'
);
console
.
error
(
`failed to perform action, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
info
(
'
perform action success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to perform action, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to perform action, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
### performAction
...
...
@@ -922,13 +922,13 @@ let parameters = {
try
{
rootElement
.
performAction
(
actionName
,
parameters
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to perform action, because ${JSON.stringify(err)}
'
);
console
.
error
(
`failed to perform action, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
console
.
info
(
'
perform action success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to perform action, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to perform action, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
### findElement('content')
...
...
@@ -962,11 +962,11 @@ try {
rootElement
.
findElement
(
type
,
condition
).
then
((
data
)
=>
{
elements
=
data
;
console
.
log
(
'
find element success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
err
)}
`
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
### findElement('content')
...
...
@@ -994,14 +994,14 @@ let elements;
try
{
rootElement
.
findElement
(
type
,
condition
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(err)}
'
);
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
elements
=
data
;
console
.
info
(
'
find element success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
### findElement('focusType')
...
...
@@ -1035,11 +1035,11 @@ try {
rootElement
.
findElement
(
type
,
condition
).
then
((
data
)
=>
{
element
=
data
;
console
.
log
(
'
find element success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
err
)}
`
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
### findElement('focusType')
...
...
@@ -1067,14 +1067,14 @@ let element;
try
{
rootElement
.
findElement
(
type
,
condition
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(err)}
'
);
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
element
=
data
;
console
.
info
(
'
find element success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
### findElement('focusDirection')
...
...
@@ -1108,11 +1108,11 @@ try {
rootElement
.
findElement
(
type
,
condition
).
then
((
data
)
=>
{
element
=
data
;
console
.
log
(
'
find element success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(err)}
'
);
}).
catch
((
err
:
object
)
=>
{
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
err
)}
`
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
### findElement('focusDirection')
...
...
@@ -1140,13 +1140,13 @@ let elements;
try
{
rootElement
.
findElement
(
type
,
condition
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(err)}
'
);
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
err
)}
`
);
return
;
}
elements
=
data
;
console
.
info
(
'
find element success
'
);
});
}
catch
(
exception
)
{
console
.
error
(
'
failed to find element, because ${JSON.stringify(exception)}
'
);
console
.
error
(
`failed to find element, because
${
JSON
.
stringify
(
exception
)}
`
);
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录