未验证 提交 90b30801 编写于 作者: O openharmony_ci 提交者: Gitee

!22875 Accessibility ArkTS规范整改

Merge pull request !22875 from zhanghuiyu/master
...@@ -44,5 +44,7 @@ constructor(durationTime: number); ...@@ -44,5 +44,7 @@ constructor(durationTime: number);
**示例:** **示例:**
```ts ```ts
import GesturePath from '@ohos.accessibility.GesturePath';
let gesturePath = new GesturePath.GesturePath(20); let gesturePath = new GesturePath.GesturePath(20);
``` ```
...@@ -45,5 +45,7 @@ constructor(positionX: number, positionY: number); ...@@ -45,5 +45,7 @@ constructor(positionX: number, positionY: number);
**示例:** **示例:**
```ts ```ts
import GesturePoint from '@ohos.accessibility.GesturePoint';
let gesturePoint = new GesturePoint.GesturePoint(1, 2); let gesturePoint = new GesturePoint.GesturePoint(1, 2);
``` ```
...@@ -68,12 +68,14 @@ enableAbility(name: string, capability: Array<accessibility.Capability>): ...@@ -68,12 +68,14 @@ enableAbility(name: string, capability: Array<accessibility.Capability>):
```ts ```ts
import accessibility from '@ohos.accessibility'; 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']; let capability : accessibility.Capability[] = ['retrieve'];
try { try {
config.enableAbility(name, capability).then(() => { config.enableAbility(name, capability).then(() => {
console.info('enable ability succeed'); console.info('enable ability succeed');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to enable ability, because ' + JSON.stringify(err)); console.error('failed to enable ability, because ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
...@@ -110,10 +112,13 @@ enableAbility(name: string, capability: Array<accessibility.Capability>, c ...@@ -110,10 +112,13 @@ enableAbility(name: string, capability: Array<accessibility.Capability>, c
```ts ```ts
import accessibility from '@ohos.accessibility'; import accessibility from '@ohos.accessibility';
let name = 'com.ohos.example/axExtension'; import config from '@ohos.accessibility.config';
let capability : accessibility.Capability[] = ['retrieve']; import { BusinessError } from '@ohos.base';
let name: string = 'com.ohos.example/axExtension';
let capability: accessibility.Capability[] = ['retrieve'];
try { try {
config.enableAbility(name, capability, (err) => { config.enableAbility(name, capability, (err: BusinessError<void>) => {
if (err) { if (err) {
console.error('failed to enable ability, because ' + JSON.stringify(err)); console.error('failed to enable ability, because ' + JSON.stringify(err));
return; return;
...@@ -156,11 +161,14 @@ disableAbility(name: string): Promise&lt;void&gt;; ...@@ -156,11 +161,14 @@ disableAbility(name: string): Promise&lt;void&gt;;
**示例:** **示例:**
```ts ```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 { try {
config.disableAbility(name).then(() => { config.disableAbility(name).then(() => {
console.info('disable ability succeed'); console.info('disable ability succeed');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to disable ability, because ' + JSON.stringify(err)); console.error('failed to disable ability, because ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
...@@ -194,9 +202,13 @@ disableAbility(name: string, callback: AsyncCallback&lt;void&gt;): void; ...@@ -194,9 +202,13 @@ disableAbility(name: string, callback: AsyncCallback&lt;void&gt;): void;
**示例:** **示例:**
```ts ```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 { try {
config.disableAbility(name, (err, data) => { config.disableAbility(name, (err: BusinessError<void>) => {
if (err) { if (err) {
console.error('failed to enable ability, because ' + JSON.stringify(err)); console.error('failed to enable ability, because ' + JSON.stringify(err));
return; return;
...@@ -226,6 +238,8 @@ on(type: 'enabledAccessibilityExtensionListChange', callback: Callback&lt;void&g ...@@ -226,6 +238,8 @@ on(type: 'enabledAccessibilityExtensionListChange', callback: Callback&lt;void&g
**示例:** **示例:**
```ts ```ts
import config from '@ohos.accessibility.config';
try { try {
config.on('enabledAccessibilityExtensionListChange', () => { config.on('enabledAccessibilityExtensionListChange', () => {
console.info('subscribe enabled accessibility extension list change state success'); console.info('subscribe enabled accessibility extension list change state success');
...@@ -254,6 +268,8 @@ off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback&lt;void ...@@ -254,6 +268,8 @@ off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback&lt;void
**示例:** **示例:**
```ts ```ts
import config from '@ohos.accessibility.config';
try { try {
config.off('enabledAccessibilityExtensionListChange', () => { config.off('enabledAccessibilityExtensionListChange', () => {
console.info('Unsubscribe enabled accessibility extension list change state success'); console.info('Unsubscribe enabled accessibility extension list change state success');
...@@ -291,11 +307,13 @@ set(value: T): Promise&lt;void&gt;; ...@@ -291,11 +307,13 @@ set(value: T): Promise&lt;void&gt;;
**示例:** **示例:**
```ts ```ts
let value = true; import config from '@ohos.accessibility.config';
let value: boolean = true;
try { try {
config.highContrastText.set(value).then(() => { config.highContrastText.set(value).then(() => {
console.info('set highContrastText succeed'); console.info('set highContrastText succeed');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to set highContrastText, because ' + JSON.stringify(err)); console.error('failed to set highContrastText, because ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
...@@ -321,9 +339,12 @@ set(value: T, callback: AsyncCallback&lt;void&gt;): void; ...@@ -321,9 +339,12 @@ set(value: T, callback: AsyncCallback&lt;void&gt;): void;
**示例:** **示例:**
```ts ```ts
let value = true; import config from '@ohos.accessibility.config';
import { BusinessError } from '@ohos.base';
let value: boolean = true;
try { try {
config.highContrastText.set(value, (err, data) => { config.highContrastText.set(value, (err: BusinessError<void>) => {
if (err) { if (err) {
console.error('failed to set highContrastText, because ' + JSON.stringify(err)); console.error('failed to set highContrastText, because ' + JSON.stringify(err));
return; return;
...@@ -352,11 +373,14 @@ get(): Promise&lt;T&gt;; ...@@ -352,11 +373,14 @@ get(): Promise&lt;T&gt;;
**示例:** **示例:**
```ts ```ts
let value; import config from '@ohos.accessibility.config';
config.highContrastText.get().then((data) => { import { BusinessError } from '@ohos.base';
let value: boolean;
config.highContrastText.get().then((data: boolean) => {
value = data; value = data;
console.info('get highContrastText success'); console.info('get highContrastText success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to get highContrastText, because ' + JSON.stringify(err)); console.error('failed to get highContrastText, because ' + JSON.stringify(err));
}); });
``` ```
...@@ -378,8 +402,11 @@ get(callback: AsyncCallback&lt;T&gt;): void; ...@@ -378,8 +402,11 @@ get(callback: AsyncCallback&lt;T&gt;): void;
**示例:** **示例:**
```ts ```ts
let value; import config from '@ohos.accessibility.config';
config.highContrastText.get((err, data) => { import { BusinessError } from '@ohos.base';
let value: boolean;
config.highContrastText.get((err: BusinessError<void>, data: boolean) => {
if (err) { if (err) {
console.error('failed to get highContrastText, because ' + JSON.stringify(err)); console.error('failed to get highContrastText, because ' + JSON.stringify(err));
return; return;
...@@ -406,8 +433,10 @@ on(callback: Callback&lt;T&gt;): void; ...@@ -406,8 +433,10 @@ on(callback: Callback&lt;T&gt;): void;
**示例:** **示例:**
```ts ```ts
import config from '@ohos.accessibility.config';
try { try {
config.highContrastText.on((data) => { config.highContrastText.on((data: boolean) => {
console.info('subscribe highContrastText success, result: ' + JSON.stringify(data)); console.info('subscribe highContrastText success, result: ' + JSON.stringify(data));
}); });
} catch (exception) { } catch (exception) {
...@@ -432,7 +461,9 @@ off(callback?: Callback&lt;T&gt;): void; ...@@ -432,7 +461,9 @@ off(callback?: Callback&lt;T&gt;): void;
**示例:** **示例:**
```ts ```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)); console.info('Unsubscribe highContrastText success, result: ' + JSON.stringify(data));
}); });
``` ```
......
...@@ -174,9 +174,11 @@ on(type: 'enableChange', callback: Callback&lt;boolean&gt;): void; ...@@ -174,9 +174,11 @@ on(type: 'enableChange', callback: Callback&lt;boolean&gt;): void;
**示例:** **示例:**
```ts ```ts
import accessibility from '@ohos.accessibility';
let captionsManager = accessibility.getCaptionsManager(); let captionsManager = accessibility.getCaptionsManager();
try { try {
captionsManager.on('enableChange', (data) => { captionsManager.on('enableChange', (data: boolean) => {
console.info('subscribe caption manager enable state change, result: ' + JSON.stringify(data)); console.info('subscribe caption manager enable state change, result: ' + JSON.stringify(data));
}); });
} catch (exception) { } catch (exception) {
...@@ -202,10 +204,12 @@ on(type: 'styleChange', callback: Callback&lt;CaptionsStyle&gt;): void; ...@@ -202,10 +204,12 @@ on(type: 'styleChange', callback: Callback&lt;CaptionsStyle&gt;): void;
**示例:** **示例:**
```ts ```ts
let captionStyle; import accessibility from '@ohos.accessibility';
let captionStyle: accessibility.CaptionsStyle;
let captionsManager = accessibility.getCaptionsManager(); let captionsManager = accessibility.getCaptionsManager();
try { try {
captionsManager.on('styleChange', (data) => { captionsManager.on('styleChange', (data: accessibility.CaptionsStyle) => {
captionStyle = data; captionStyle = data;
console.info('subscribe caption manager style state change, result: ' + JSON.stringify(data)); console.info('subscribe caption manager style state change, result: ' + JSON.stringify(data));
}); });
...@@ -232,9 +236,11 @@ off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void; ...@@ -232,9 +236,11 @@ off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void;
**示例:** **示例:**
```ts ```ts
import accessibility from '@ohos.accessibility';
let captionsManager = accessibility.getCaptionsManager(); let captionsManager = accessibility.getCaptionsManager();
try { try {
captionsManager.off('enableChange', (data) => { captionsManager.off('enableChange', (data: boolean) => {
console.info('Unsubscribe caption manager enable state change, result: ' + JSON.stringify(data)); console.info('Unsubscribe caption manager enable state change, result: ' + JSON.stringify(data));
}); });
} catch (exception) { } catch (exception) {
...@@ -260,10 +266,12 @@ off(type: 'styleChange', callback?: Callback&lt;CaptionsStyle&gt;): void; ...@@ -260,10 +266,12 @@ off(type: 'styleChange', callback?: Callback&lt;CaptionsStyle&gt;): void;
**示例:** **示例:**
```ts ```ts
let captionStyle; import accessibility from '@ohos.accessibility';
let captionStyle: accessibility.CaptionsStyle;
let captionsManager = accessibility.getCaptionsManager(); let captionsManager = accessibility.getCaptionsManager();
try { try {
captionsManager.off('styleChange', (data) => { captionsManager.off('styleChange', (data: accessibility.CaptionsStyle) => {
captionStyle = data; captionStyle = data;
console.info('Unsubscribe caption manager style state change, result: ' + JSON.stringify(data)); console.info('Unsubscribe caption manager style state change, result: ' + JSON.stringify(data));
}); });
...@@ -314,10 +322,12 @@ constructor(jsonObject) ...@@ -314,10 +322,12 @@ constructor(jsonObject)
**示例:** **示例:**
```ts ```ts
let eventInfo = new accessibility.EventInfo({ import accessibility from '@ohos.accessibility';
'type':'click',
'bundleName':'com.example.MyApplication', let eventInfo: accessibility.EventInfo = ({
'triggerAction':'click' type: 'click',
bundleName: 'com.example.MyApplication',
triggerAction: 'click'
}); });
``` ```
...@@ -398,20 +408,24 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise&lt;A ...@@ -398,20 +408,24 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise&lt;A
**示例:** **示例:**
```ts ```ts
let abilityType = 'spoken'; import accessibility from '@ohos.accessibility';
let abilityState = 'enable';
let abilityList: accessibility.AccessibilityInfo[]; let abilityType : accessibility.AbilityType = 'spoken';
let abilityState : accessibility.AbilityState = 'enable';
let abilityList: accessibility.AccessibilityAbilityInfo[];
try { try {
accessibility.getAbilityLists(abilityType, abilityState).then((data) => { accessibility.getAbilityLists(abilityType, abilityState)
.then((data: accessibility.AccessibilityAbilityInfo[]) => {
for (let item of data) { for (let item of data) {
console.info(item.id); console.info(item.id);
console.info(item.name); console.info(item.name);
console.info(item.description); console.info(item.description);
console.info(item.bundleName); console.info(item.bundleName);
extensionList.push(item); abilityList.push(item);
} }
console.info('get accessibility extension list success'); console.info('get accessibility extension list success');
}).catch((err) => { })
.catch((err: object) => {
console.error('failed to get accessibility extension list because ' + JSON.stringify(err)); console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
...@@ -443,11 +457,15 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: Asyn ...@@ -443,11 +457,15 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: Asyn
**示例:** **示例:**
```ts ```ts
let abilityType = 'spoken'; import accessibility from '@ohos.accessibility';
let abilityState = 'enable'; import { BusinessError } from '@ohos.base';
let abilityType : accessibility.AbilityType = 'spoken';
let abilityState : accessibility.AbilityState = 'enable';
let abilityList: accessibility.AccessibilityInfo[]; let abilityList: accessibility.AccessibilityInfo[];
try { try {
accessibility.getAbilityLists(abilityType, abilityState, (err, data) => { accessibility.getAbilityLists(abilityType, abilityState,
(err: BusinessError<void>, data: accessibility.AccessibilityAbilityInfo[]) => {
if (err) { if (err) {
console.error('failed to get accessibility extension list because ' + JSON.stringify(err)); console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
return; return;
...@@ -460,9 +478,7 @@ try { ...@@ -460,9 +478,7 @@ try {
abilityList.push(item); abilityList.push(item);
} }
console.info('get accessibility extension list success'); console.info('get accessibility extension list success');
}).catch((err) => { })
console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
});
} catch (exception) { } 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));
} }
...@@ -492,11 +508,14 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState) ...@@ -492,11 +508,14 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState)
**示例:** **示例:**
```ts ```ts
import accessibility from '@ohos.accessibility';
let abilityType : accessibility.AbilityType = 'spoken'; let abilityType : accessibility.AbilityType = 'spoken';
let abilityState : accessibility.AbilityState = 'enable'; let abilityState : accessibility.AbilityState = 'enable';
let extensionList: accessibility.AccessibilityAbilityInfo[] = []; let extensionList: accessibility.AccessibilityAbilityInfo[] = [];
try { try {
accessibility.getAccessibilityExtensionList(abilityType, abilityState).then((data) => { accessibility.getAccessibilityExtensionList(abilityType, abilityState)
.then((data: accessibility.AccessibilityAbilityInfo[]) => {
for (let item of data) { for (let item of data) {
console.info(item.id); console.info(item.id);
console.info(item.name); console.info(item.name);
...@@ -505,7 +524,8 @@ try { ...@@ -505,7 +524,8 @@ try {
extensionList.push(item); extensionList.push(item);
} }
console.info('get accessibility extension list success'); console.info('get accessibility extension list success');
}).catch((err) => { })
.catch((err: object) => {
console.error('failed to get accessibility extension list because ' + JSON.stringify(err)); console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
...@@ -532,11 +552,15 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, ...@@ -532,11 +552,15 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState,
**示例:** **示例:**
```ts ```ts
import accessibility from '@ohos.accessibility';
import { BusinessError } from '@ohos.base';
let abilityType : accessibility.AbilityType = 'spoken'; let abilityType : accessibility.AbilityType = 'spoken';
let abilityState : accessibility.AbilityState = 'enable'; let abilityState : accessibility.AbilityState = 'enable';
let extensionList: accessibility.AccessibilityAbilityInfo[] = []; let extensionList: accessibility.AccessibilityAbilityInfo[] = [];
try { try {
accessibility.getAccessibilityExtensionList(abilityType, abilityState, (err, data) => { accessibility.getAccessibilityExtensionList(abilityType, abilityState,
(err: BusinessError<void>, data: accessibility.AccessibilityAbilityInfo[]) => {
if (err) { if (err) {
console.error('failed to get accessibility extension list because ' + JSON.stringify(err)); console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
return; return;
...@@ -572,6 +596,8 @@ getCaptionsManager(): CaptionsManager ...@@ -572,6 +596,8 @@ getCaptionsManager(): CaptionsManager
**示例:** **示例:**
```ts ```ts
import accessibility from '@ohos.accessibility';
let captionsManager = accessibility.getCaptionsManager(); let captionsManager = accessibility.getCaptionsManager();
``` ```
...@@ -593,8 +619,10 @@ on(type: 'accessibilityStateChange', callback: Callback&lt;boolean&gt;): void ...@@ -593,8 +619,10 @@ on(type: 'accessibilityStateChange', callback: Callback&lt;boolean&gt;): void
**示例:** **示例:**
```ts ```ts
import accessibility from '@ohos.accessibility';
try { try {
accessibility.on('accessibilityStateChange', (data) => { accessibility.on('accessibilityStateChange', (data: boolean) => {
console.info('subscribe accessibility state change, result: ' + JSON.stringify(data)); console.info('subscribe accessibility state change, result: ' + JSON.stringify(data));
}); });
} catch (exception) { } catch (exception) {
...@@ -620,8 +648,10 @@ on(type: 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void ...@@ -620,8 +648,10 @@ on(type: 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void
**示例:** **示例:**
```ts ```ts
import accessibility from '@ohos.accessibility';
try { try {
accessibility.on('touchGuideStateChange', (data) => { accessibility.on('touchGuideStateChange', (data: boolean) => {
console.info('subscribe touch guide state change, result: ' + JSON.stringify(data)); console.info('subscribe touch guide state change, result: ' + JSON.stringify(data));
}); });
} catch (exception) { } catch (exception) {
...@@ -647,8 +677,10 @@ off(type: 'accessibilityStateChange', callback?: Callback&lt;boolean&gt;): void ...@@ -647,8 +677,10 @@ off(type: 'accessibilityStateChange', callback?: Callback&lt;boolean&gt;): void
**示例:** **示例:**
```ts ```ts
import accessibility from '@ohos.accessibility';
try { try {
accessibility.off('accessibilityStateChange', (data) => { accessibility.off('accessibilityStateChange', (data: boolean) => {
console.info('Unsubscribe accessibility state change, result: ' + JSON.stringify(data)); console.info('Unsubscribe accessibility state change, result: ' + JSON.stringify(data));
}); });
} catch (exception) { } catch (exception) {
...@@ -674,8 +706,10 @@ off(type: 'touchGuideStateChange', callback?: Callback&lt;boolean&gt;): void ...@@ -674,8 +706,10 @@ off(type: 'touchGuideStateChange', callback?: Callback&lt;boolean&gt;): void
**示例:** **示例:**
```ts ```ts
import accessibility from '@ohos.accessibility';
try { try {
accessibility.off('touchGuideStateChange', (data) => { accessibility.off('touchGuideStateChange', (data: boolean) => {
console.info('Unsubscribe touch guide state change, result: ' + JSON.stringify(data)); console.info('Unsubscribe touch guide state change, result: ' + JSON.stringify(data));
}); });
} catch (exception) { } catch (exception) {
...@@ -700,9 +734,11 @@ isOpenAccessibility(): Promise&lt;boolean&gt; ...@@ -700,9 +734,11 @@ isOpenAccessibility(): Promise&lt;boolean&gt;
**示例:** **示例:**
```ts ```ts
accessibility.isOpenAccessibility().then((data) => { import accessibility from '@ohos.accessibility';
accessibility.isOpenAccessibility().then((data: boolean) => {
console.info('success data:isOpenAccessibility : ' + JSON.stringify(data)) console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
}).catch((err) => { }).catch((err: object) => {
console.error('failed to isOpenAccessibility because ' + JSON.stringify(err)); console.error('failed to isOpenAccessibility because ' + JSON.stringify(err));
}); });
``` ```
...@@ -724,7 +760,10 @@ isOpenAccessibility(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -724,7 +760,10 @@ isOpenAccessibility(callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
```ts ```ts
accessibility.isOpenAccessibility((err, data) => { import accessibility from '@ohos.accessibility';
import { BusinessError } from '@ohos.base';
accessibility.isOpenAccessibility((err: BusinessError<void>, data: boolean) => {
if (err) { if (err) {
console.error('failed to isOpenAccessibility because ' + JSON.stringify(err)); console.error('failed to isOpenAccessibility because ' + JSON.stringify(err));
return; return;
...@@ -750,9 +789,11 @@ isOpenTouchGuide(): Promise&lt;boolean&gt; ...@@ -750,9 +789,11 @@ isOpenTouchGuide(): Promise&lt;boolean&gt;
**示例:** **示例:**
```ts ```ts
accessibility.isOpenTouchGuide().then((data) => { import accessibility from '@ohos.accessibility';
accessibility.isOpenTouchGuide().then((data: boolean) => {
console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data)) console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
}).catch((err) => { }).catch((err: object) => {
console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err)); console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err));
}); });
``` ```
...@@ -774,7 +815,10 @@ isOpenTouchGuide(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -774,7 +815,10 @@ isOpenTouchGuide(callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
```ts ```ts
accessibility.isOpenTouchGuide((err, data) => { import accessibility from '@ohos.accessibility';
import { BusinessError } from '@ohos.base';
accessibility.isOpenTouchGuide((err: BusinessError<void>, data: boolean) => {
if (err) { if (err) {
console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err)); console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err));
return; return;
...@@ -811,14 +855,16 @@ sendEvent(event: EventInfo): Promise&lt;void&gt; ...@@ -811,14 +855,16 @@ sendEvent(event: EventInfo): Promise&lt;void&gt;
**示例:** **示例:**
```ts ```ts
let eventInfo = new accessibility.EventInfo({ import accessibility from '@ohos.accessibility';
'type':'click',
'bundleName':'com.example.MyApplication', let eventInfo: accessibility.EventInfo = ({
'triggerAction':'click' type: 'click',
bundleName: 'com.example.MyApplication',
triggerAction: 'click'
}); });
accessibility.sendEvent(eventInfo).then(() => { accessibility.sendEvent(eventInfo).then(() => {
console.info('send event success'); console.info('send event success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to sendEvent because ' + JSON.stringify(err)); console.error('failed to sendEvent because ' + JSON.stringify(err));
}); });
``` ```
...@@ -846,12 +892,15 @@ sendEvent(event: EventInfo, callback: AsyncCallback&lt;void&gt;): void ...@@ -846,12 +892,15 @@ sendEvent(event: EventInfo, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```ts ```ts
let eventInfo = new accessibility.EventInfo({ import accessibility from '@ohos.accessibility';
'type':'click', import { BusinessError } from '@ohos.base';
'bundleName':'com.example.MyApplication',
'triggerAction':'click' 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) { if (err) {
console.error('failed to sendEvent because ' + JSON.stringify(err)); console.error('failed to sendEvent because ' + JSON.stringify(err));
return; return;
...@@ -883,15 +932,17 @@ sendAccessibilityEvent(event: EventInfo): Promise&lt;void&gt; ...@@ -883,15 +932,17 @@ sendAccessibilityEvent(event: EventInfo): Promise&lt;void&gt;
**示例:** **示例:**
```ts ```ts
let eventInfo = new accessibility.EventInfo({ import accessibility from '@ohos.accessibility';
'type':'click',
'bundleName':'com.example.MyApplication', let eventInfo: accessibility.EventInfo = ({
'triggerAction':'click' type: 'click',
bundleName: 'com.example.MyApplication',
triggerAction: 'click'
}); });
try { try {
accessibility.sendAccessibilityEvent(eventInfo).then(() => { accessibility.sendAccessibilityEvent(eventInfo).then(() => {
console.info('send event success'); console.info('send event success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to send event because ' + JSON.stringify(err)); console.error('failed to send event because ' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
...@@ -917,13 +968,16 @@ sendAccessibilityEvent(event: EventInfo, callback: AsyncCallback&lt;void&gt;): v ...@@ -917,13 +968,16 @@ sendAccessibilityEvent(event: EventInfo, callback: AsyncCallback&lt;void&gt;): v
**示例:** **示例:**
```ts ```ts
let eventInfo = new accessibility.EventInfo({ import accessibility from '@ohos.accessibility';
'type':'click', import { BusinessError } from '@ohos.base';
'bundleName':'com.example.MyApplication',
'triggerAction':'click' let eventInfo: accessibility.EventInfo = ({
type: 'click',
bundleName: 'com.example.MyApplication',
triggerAction: 'click'
}); });
try { try {
accessibility.sendEvent(eventInfo, (err, data) => { accessibility.sendEvent(eventInfo, (err: BusinessError<void>) => {
if (err) { if (err) {
console.error('failed to send event because ' + JSON.stringify(err)); console.error('failed to send event because ' + JSON.stringify(err));
return; return;
......
...@@ -92,11 +92,13 @@ onConnect(): void; ...@@ -92,11 +92,13 @@ onConnect(): void;
**示例:** **示例:**
```ts ```ts
import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
onConnect() { onConnect(): void {
console.log('AxExtensionAbility onConnect'); console.log('AxExtensionAbility onConnect');
} }
}; }
``` ```
## AccessibilityExtensionAbility.onDisconnect ## AccessibilityExtensionAbility.onDisconnect
...@@ -110,11 +112,13 @@ onDisconnect(): void; ...@@ -110,11 +112,13 @@ onDisconnect(): void;
**示例:** **示例:**
```ts ```ts
import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
onDisconnect() { onDisconnect(): void {
console.log('AxExtensionAbility onDisconnect'); console.log('AxExtensionAbility onDisconnect');
} }
}; }
``` ```
## AccessibilityExtensionAbility.onAccessibilityEvent ## AccessibilityExtensionAbility.onAccessibilityEvent
...@@ -134,14 +138,16 @@ onAccessibilityEvent(event: AccessibilityEvent): void; ...@@ -134,14 +138,16 @@ onAccessibilityEvent(event: AccessibilityEvent): void;
**示例:** **示例:**
```ts ```ts
import AccessibilityExtensionAbility , { AccessibilityEvent } from '@ohos.application.AccessibilityExtensionAbility';
class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
onAccessibilityEvent(event) { onAccessibilityEvent(event: AccessibilityEvent): void {
console.log('AxExtensionAbility onAccessibilityEvent'); console.log('AxExtensionAbility onAccessibilityEvent');
if (event.eventType === 'click') { if (event.eventType === 'click') {
console.log('AxExtensionAbility onAccessibilityEvent: click'); console.log('AxExtensionAbility onAccessibilityEvent: click');
} }
} }
}; }
``` ```
## AccessibilityExtensionAbility.onKeyEvent ## AccessibilityExtensionAbility.onKeyEvent
...@@ -161,14 +167,17 @@ onKeyEvent(keyEvent: KeyEvent): boolean; ...@@ -161,14 +167,17 @@ onKeyEvent(keyEvent: KeyEvent): boolean;
**示例:** **示例:**
```ts ```ts
import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
import { KeyEvent } from '@ohos.multimodalInput.keyEvent';
class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility { class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
onKeyEvent(keyEvent) { onKeyEvent(keyEvent: KeyEvent): boolean {
console.log('AxExtensionAbility onKeyEvent'); console.log('AxExtensionAbility onKeyEvent');
if (keyEvent.keyCode === 22) { if (keyEvent.key.code === 16) {
console.log('AxExtensionAbility onKeyEvent: intercept 22'); console.log('AxExtensionAbility onKeyEvent: intercept 16');
return true; return true;
} }
return false; return false;
} }
}; }
``` ```
...@@ -102,11 +102,11 @@ let targetNames = ['com.ohos.xyz']; ...@@ -102,11 +102,11 @@ let targetNames = ['com.ohos.xyz'];
try { try {
axContext.setTargetBundleName(targetNames).then(() => { axContext.setTargetBundleName(targetNames).then(() => {
console.info('set target bundle names success'); console.info('set target bundle names success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to set target bundle names, because ${JSON.stringify(err)}'); console.error(`failed to set target bundle names, because ${JSON.stringify(err)}`);
}); });
} catch (exception) { } 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>) ...@@ -131,14 +131,14 @@ setTargetBundleName(targetNames: Array\<string>, callback: AsyncCallback\<void>)
let targetNames = ['com.ohos.xyz']; let targetNames = ['com.ohos.xyz'];
try { try {
axContext.setTargetBundleName(targetNames, (err, data) => { axContext.setTargetBundleName(targetNames, (err, data) => {
if (err && err.code) { if (err) {
console.error('failed to set target bundle names, because ${JSON.stringify(err)}'); console.error(`failed to set target bundle names, because ${JSON.stringify(err)}`);
return; return;
} }
console.info('set target bundle names success'); console.info('set target bundle names success');
}); });
} catch (exception) { } 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 { ...@@ -178,11 +178,11 @@ try {
axContext.getFocusElement().then((data) => { axContext.getFocusElement().then((data) => {
focusElement = data; focusElement = data;
console.log('get focus element success'); console.log('get focus element success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to get focus element, because ${JSON.stringify(err)}'); console.error(`failed to get focus element, because ${JSON.stringify(err)}`);
}); });
} catch (exception) { } 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; ...@@ -214,15 +214,15 @@ getFocusElement(callback: AsyncCallback\<AccessibilityElement>): void;
let focusElement; let focusElement;
try { try {
axContext.getFocusElement((err, data) => { axContext.getFocusElement((err, data) => {
if (err && err.code) { if (err) {
console.error('failed to get focus element, because ${JSON.stringify(err)}'); console.error(`failed to get focus element, because ${JSON.stringify(err)}`);
return; return;
} }
focusElement = data; focusElement = data;
console.info('get focus element success'); console.info('get focus element success');
}); });
} catch (exception) { } 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; ...@@ -256,15 +256,15 @@ let focusElement;
let isAccessibilityFocus = true; let isAccessibilityFocus = true;
try { try {
axContext.getFocusElement(isAccessibilityFocus, (err, data) => { axContext.getFocusElement(isAccessibilityFocus, (err, data) => {
if (err && err.code) { if (err) {
console.error('failed to get focus element, because ${JSON.stringify(err)}'); console.error(`failed to get focus element, because ${JSON.stringify(err)}`);
return; return;
} }
focusElement = data; focusElement = data;
console.info('get focus element success'); console.info('get focus element success');
}); });
} catch (exception) { } 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 ## AccessibilityExtensionContext.getWindowRootElement
...@@ -303,11 +303,11 @@ try { ...@@ -303,11 +303,11 @@ try {
axContext.getWindowRootElement().then((data) => { axContext.getWindowRootElement().then((data) => {
rootElement = data; rootElement = data;
console.log('get root element of the window success'); console.log('get root element of the window success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to get root element of the window, because ${JSON.stringify(err)}'); console.error(`failed to get root element of the window, because ${JSON.stringify(err)}`);
}); });
} catch (exception) { } 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; ...@@ -339,15 +339,15 @@ getWindowRootElement(callback: AsyncCallback\<AccessibilityElement>): void;
let rootElement; let rootElement;
try { try {
axContext.getWindowRootElement((err, data) => { axContext.getWindowRootElement((err, data) => {
if (err && err.code) { if (err) {
console.error('failed to get root element of the window, because ${JSON.stringify(err)}'); console.error(`failed to get root element of the window, because ${JSON.stringify(err)}`);
return; return;
} }
rootElement = data; rootElement = data;
console.info('get root element of the window success'); console.info('get root element of the window success');
}); });
} catch (exception) { } 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; ...@@ -381,15 +381,15 @@ let rootElement;
let windowId = 10; let windowId = 10;
try { try {
axContext.getWindowRootElement(windowId, (err, data) => { axContext.getWindowRootElement(windowId, (err, data) => {
if (err && err.code) { if (err) {
console.error('failed to get root element of the window, because ${JSON.stringify(err)}'); console.error(`failed to get root element of the window, because ${JSON.stringify(err)}`);
return; return;
} }
rootElement = data; rootElement = data;
console.info('get root element of the window success'); console.info('get root element of the window success');
}); });
} catch (exception) { } 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 { ...@@ -429,11 +429,11 @@ try {
axContext.getWindows().then((data) => { axContext.getWindows().then((data) => {
windows = data; windows = data;
console.log('get windows success'); console.log('get windows success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to get windows, because ${JSON.stringify(err)}'); console.error(`failed to get windows, because ${JSON.stringify(err)}`);
}); });
} catch (exception) { } 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; ...@@ -465,15 +465,15 @@ getWindows(callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
let windows; let windows;
try { try {
axContext.getWindows((err, data) => { axContext.getWindows((err, data) => {
if (err && err.code) { if (err) {
console.error('failed to get windows, because ${JSON.stringify(err)}'); console.error(`failed to get windows, because ${JSON.stringify(err)}`);
return; return;
} }
windows = data; windows = data;
console.info('get windows success'); console.info('get windows success');
}); });
} catch (exception) { } 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; ...@@ -507,15 +507,15 @@ let windows;
let displayId = 10; let displayId = 10;
try { try {
axContext.getWindows(displayId, (err, data) => { axContext.getWindows(displayId, (err, data) => {
if (err && err.code) { if (err) {
console.error('failed to get windows, because ${JSON.stringify(err)}'); console.error(`failed to get windows, because ${JSON.stringify(err)}`);
return; return;
} }
windows = data; windows = data;
console.info('get windows success'); console.info('get windows success');
}); });
} catch (exception) { } 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 { ...@@ -560,11 +560,11 @@ try {
} }
axContext.injectGesture(gesturePath).then(() => { axContext.injectGesture(gesturePath).then(() => {
console.info('inject gesture success'); console.info('inject gesture success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to inject gesture, because ${JSON.stringify(err)}'); console.error(`failed to inject gesture, because ${JSON.stringify(err)}`);
}); });
} catch (exception) { } catch (exception) {
console.error('failed to inject gesture, because ${JSON.stringify(exception)}'); console.error(`failed to inject gesture, because ${JSON.stringify(exception)}`);
} }
``` ```
## AccessibilityExtensionContext.injectGesture ## AccessibilityExtensionContext.injectGesture
...@@ -602,14 +602,14 @@ try { ...@@ -602,14 +602,14 @@ try {
gesturePath.points.push(gesturePoint); gesturePath.points.push(gesturePoint);
} }
axContext.injectGesture(gesturePath, (err, data) => { axContext.injectGesture(gesturePath, (err, data) => {
if (err && err.code) { if (err) {
console.error('failed to inject gesture, because ${JSON.stringify(err)}'); console.error(`failed to inject gesture, because ${JSON.stringify(err)}`);
return; return;
} }
console.info('inject gesture success'); console.info('inject gesture success');
}); });
} catch (exception) { } 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> ## AccessibilityElement<sup>9+</sup>
...@@ -639,8 +639,8 @@ let attributeNames; ...@@ -639,8 +639,8 @@ let attributeNames;
rootElement.attributeNames().then((data) => { rootElement.attributeNames().then((data) => {
console.log('get attribute names success'); console.log('get attribute names success');
attributeNames = data; attributeNames = data;
}).catch((err) => { }).catch((err: object) => {
console.log('failed to get attribute names, because ${JSON.stringify(err)}'); console.log(`failed to get attribute names, because ${JSON.stringify(err)}`);
}); });
``` ```
### attributeNames ### attributeNames
...@@ -663,7 +663,7 @@ attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\ ...@@ -663,7 +663,7 @@ attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\
let attributeNames; let attributeNames;
rootElement.attributeNames((err, data) => { rootElement.attributeNames((err, data) => {
if (err) { 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; return;
} }
attributeNames = data; attributeNames = data;
...@@ -707,11 +707,11 @@ try { ...@@ -707,11 +707,11 @@ try {
rootElement.attributeValue(attributeName).then((data) => { rootElement.attributeValue(attributeName).then((data) => {
console.log('get attribute value by name success'); console.log('get attribute value by name success');
attributeValue = data; attributeValue = data;
}).catch((err) => { }).catch((err: object) => {
console.error('failed to get attribute value, because ${JSON.stringify(err)}'); console.error(`failed to get attribute value, because ${JSON.stringify(err)}`);
}); });
} catch (exception) { } 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 ### attributeValue
...@@ -746,14 +746,14 @@ let attributeName = 'name'; ...@@ -746,14 +746,14 @@ let attributeName = 'name';
try { try {
rootElement.attributeValue(attributeName, (err, data) => { rootElement.attributeValue(attributeName, (err, data) => {
if (err) { 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; return;
} }
attributeValue = data; attributeValue = data;
console.info('get attribute value success'); console.info('get attribute value success');
}); });
} catch (exception) { } 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 ### actionNames
...@@ -777,8 +777,8 @@ let actionNames; ...@@ -777,8 +777,8 @@ let actionNames;
rootElement.actionNames().then((data) => { rootElement.actionNames().then((data) => {
console.log('get action names success'); console.log('get action names success');
actionNames = data; actionNames = data;
}).catch((err) => { }).catch((err: object) => {
console.error('failed to get action names because ${JSON.stringify(err)}'); console.error(`failed to get action names because ${JSON.stringify(err)}`);
}); });
``` ```
### actionNames ### actionNames
...@@ -801,7 +801,7 @@ actionNames(callback: AsyncCallback\<Array\<string>>): void; ...@@ -801,7 +801,7 @@ actionNames(callback: AsyncCallback\<Array\<string>>): void;
let actionNames; let actionNames;
rootElement.actionNames((err, data) => { rootElement.actionNames((err, data) => {
if (err) { 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; return;
} }
actionNames = data; actionNames = data;
...@@ -843,11 +843,11 @@ performAction(actionName: string, parameters?: object): Promise\<void>; ...@@ -843,11 +843,11 @@ performAction(actionName: string, parameters?: object): Promise\<void>;
try { try {
rootElement.performAction('action').then((data) => { rootElement.performAction('action').then((data) => {
console.info('perform action success'); console.info('perform action success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to perform action, because ${JSON.stringify(err)}'); console.error(`failed to perform action, because ${JSON.stringify(err)}`);
}); });
} catch (exception) { } catch (exception) {
console.error('failed to perform action, because ${JSON.stringify(exception)}'); console.error(`failed to perform action, because ${JSON.stringify(exception)}`);
} }
``` ```
### performAction ### performAction
...@@ -879,13 +879,13 @@ performAction(actionName: string, callback: AsyncCallback\<void>): void; ...@@ -879,13 +879,13 @@ performAction(actionName: string, callback: AsyncCallback\<void>): void;
try { try {
rootElement.performAction('action', (err, data) => { rootElement.performAction('action', (err, data) => {
if (err) { if (err) {
console.error('failed to perform action, because ${JSON.stringify(err)}'); console.error(`failed to perform action, because ${JSON.stringify(err)}`);
return; return;
} }
console.info('perform action success'); console.info('perform action success');
}); });
} catch (exception) { } catch (exception) {
console.error('failed to perform action, because ${JSON.stringify(exception)}'); console.error(`failed to perform action, because ${JSON.stringify(exception)}`);
} }
``` ```
### performAction ### performAction
...@@ -922,13 +922,13 @@ let parameters = { ...@@ -922,13 +922,13 @@ let parameters = {
try { try {
rootElement.performAction(actionName, parameters, (err, data) => { rootElement.performAction(actionName, parameters, (err, data) => {
if (err) { if (err) {
console.error('failed to perform action, because ${JSON.stringify(err)}'); console.error(`failed to perform action, because ${JSON.stringify(err)}`);
return; return;
} }
console.info('perform action success'); console.info('perform action success');
}); });
} catch (exception) { } catch (exception) {
console.error('failed to perform action, because ${JSON.stringify(exception)}'); console.error(`failed to perform action, because ${JSON.stringify(exception)}`);
} }
``` ```
### findElement('content') ### findElement('content')
...@@ -962,11 +962,11 @@ try { ...@@ -962,11 +962,11 @@ try {
rootElement.findElement(type, condition).then((data) => { rootElement.findElement(type, condition).then((data) => {
elements = data; elements = data;
console.log('find element success'); console.log('find element success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to find element, because ${JSON.stringify(err)}'); console.error(`failed to find element, because ${JSON.stringify(err)}`);
}); });
} catch (exception) { } catch (exception) {
console.error('failed to find element, because ${JSON.stringify(exception)}'); console.error(`failed to find element, because ${JSON.stringify(exception)}`);
} }
``` ```
### findElement('content') ### findElement('content')
...@@ -994,14 +994,14 @@ let elements; ...@@ -994,14 +994,14 @@ let elements;
try { try {
rootElement.findElement(type, condition, (err, data) => { rootElement.findElement(type, condition, (err, data) => {
if (err) { if (err) {
console.error('failed to find element, because ${JSON.stringify(err)}'); console.error(`failed to find element, because ${JSON.stringify(err)}`);
return; return;
} }
elements = data; elements = data;
console.info('find element success'); console.info('find element success');
}); });
} catch (exception) { } catch (exception) {
console.error('failed to find element, because ${JSON.stringify(exception)}'); console.error(`failed to find element, because ${JSON.stringify(exception)}`);
} }
``` ```
### findElement('focusType') ### findElement('focusType')
...@@ -1035,11 +1035,11 @@ try { ...@@ -1035,11 +1035,11 @@ try {
rootElement.findElement(type, condition).then((data) => { rootElement.findElement(type, condition).then((data) => {
element = data; element = data;
console.log('find element success'); console.log('find element success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to find element, because ${JSON.stringify(err)}'); console.error(`failed to find element, because ${JSON.stringify(err)}`);
}); });
} catch (exception) { } catch (exception) {
console.error('failed to find element, because ${JSON.stringify(exception)}'); console.error(`failed to find element, because ${JSON.stringify(exception)}`);
} }
``` ```
### findElement('focusType') ### findElement('focusType')
...@@ -1067,14 +1067,14 @@ let element; ...@@ -1067,14 +1067,14 @@ let element;
try { try {
rootElement.findElement(type, condition, (err, data) => { rootElement.findElement(type, condition, (err, data) => {
if (err) { if (err) {
console.error('failed to find element, because ${JSON.stringify(err)}'); console.error(`failed to find element, because ${JSON.stringify(err)}`);
return; return;
} }
element = data; element = data;
console.info('find element success'); console.info('find element success');
}); });
} catch (exception) { } catch (exception) {
console.error('failed to find element, because ${JSON.stringify(exception)}'); console.error(`failed to find element, because ${JSON.stringify(exception)}`);
} }
``` ```
### findElement('focusDirection') ### findElement('focusDirection')
...@@ -1108,11 +1108,11 @@ try { ...@@ -1108,11 +1108,11 @@ try {
rootElement.findElement(type, condition).then((data) => { rootElement.findElement(type, condition).then((data) => {
element = data; element = data;
console.log('find element success'); console.log('find element success');
}).catch((err) => { }).catch((err: object) => {
console.error('failed to find element, because ${JSON.stringify(err)}'); console.error(`failed to find element, because ${JSON.stringify(err)}`);
}); });
} catch (exception) { } catch (exception) {
console.error('failed to find element, because ${JSON.stringify(exception)}'); console.error(`failed to find element, because ${JSON.stringify(exception)}`);
} }
``` ```
### findElement('focusDirection') ### findElement('focusDirection')
...@@ -1140,13 +1140,13 @@ let elements; ...@@ -1140,13 +1140,13 @@ let elements;
try { try {
rootElement.findElement(type, condition, (err, data) => { rootElement.findElement(type, condition, (err, data) => {
if (err) { if (err) {
console.error('failed to find element, because ${JSON.stringify(err)}'); console.error(`failed to find element, because ${JSON.stringify(err)}`);
return; return;
} }
elements = data; elements = data;
console.info('find element success'); console.info('find element success');
}); });
} catch (exception) { } 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.
先完成此消息的编辑!
想要评论请 注册