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

!11638 修复无障碍子系统文档中的示例代码问题

Merge pull request !11638 from zaki/master
...@@ -64,6 +64,7 @@ enableAbility(name: string, capability: Array<accessibility.Capability>): ...@@ -64,6 +64,7 @@ enableAbility(name: string, capability: Array<accessibility.Capability>):
**示例:** **示例:**
```ts ```ts
import accessibility from '@ohos.accessibility';
let name = 'com.ohos.example/axExtension'; let name = 'com.ohos.example/axExtension';
let capability : accessibility.Capability[] = ['retrieve']; let capability : accessibility.Capability[] = ['retrieve'];
try { try {
...@@ -105,6 +106,7 @@ enableAbility(name: string, capability: Array<accessibility.Capability>, c ...@@ -105,6 +106,7 @@ enableAbility(name: string, capability: Array<accessibility.Capability>, c
**示例:** **示例:**
```ts ```ts
import accessibility from '@ohos.accessibility';
let name = 'com.ohos.example/axExtension'; let name = 'com.ohos.example/axExtension';
let capability : accessibility.Capability[] = ['retrieve']; let capability : accessibility.Capability[] = ['retrieve'];
try { try {
......
...@@ -210,6 +210,7 @@ getFocusElement(callback: AsyncCallback\<AccessibilityElement>): void; ...@@ -210,6 +210,7 @@ getFocusElement(callback: AsyncCallback\<AccessibilityElement>): void;
**示例:** **示例:**
```ts ```ts
let focusElement;
try { try {
axContext.getFocusElement((err, data) => { axContext.getFocusElement((err, data) => {
if (err) { if (err) {
...@@ -242,6 +243,7 @@ getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\<Accessib ...@@ -242,6 +243,7 @@ getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\<Accessib
**示例:** **示例:**
```ts ```ts
let focusElement;
try { try {
axContext.getFocusElement(isAccessibilityFocus, (err, data) => { axContext.getFocusElement(isAccessibilityFocus, (err, data) => {
if (err) { if (err) {
...@@ -324,6 +326,7 @@ getWindowRootElement(callback: AsyncCallback\<AccessibilityElement>): void; ...@@ -324,6 +326,7 @@ getWindowRootElement(callback: AsyncCallback\<AccessibilityElement>): void;
**示例:** **示例:**
```ts ```ts
let rootElement;
try { try {
axContext.getWindowRootElement((err, data) => { axContext.getWindowRootElement((err, data) => {
if (err) { if (err) {
...@@ -364,6 +367,7 @@ getWindowRootElement(windowId: number, callback: AsyncCallback\<AccessibilityEle ...@@ -364,6 +367,7 @@ getWindowRootElement(windowId: number, callback: AsyncCallback\<AccessibilityEle
**示例:** **示例:**
```ts ```ts
let rootElement;
try { try {
axContext.getWindowRootElement(windowId, (err, data) => { axContext.getWindowRootElement(windowId, (err, data) => {
if (err) { if (err) {
...@@ -536,10 +540,11 @@ injectGesture(gesturePath: GesturePath): Promise\<void>; ...@@ -536,10 +540,11 @@ injectGesture(gesturePath: GesturePath): Promise\<void>;
```ts ```ts
import GesturePath from "@ohos.accessibility.GesturePath"; import GesturePath from "@ohos.accessibility.GesturePath";
let gesturePath = new GesturePath(100); import GesturePoint from '@ohos.accessibility.GesturePoint';
let gesturePath = new GesturePath.GesturePath(100);
try { try {
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
let gesturePoint = new GesturePoint(100, i * 200); let gesturePoint = new GesturePoint.GesturePoint(100, i * 200);
gesturePath.points.push(gesturePoint); gesturePath.points.push(gesturePoint);
} }
axContext.injectGesture(gesturePath).then(() => { axContext.injectGesture(gesturePath).then(() => {
...@@ -578,10 +583,11 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\<void>): void ...@@ -578,10 +583,11 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\<void>): void
```ts ```ts
import GesturePath from "@ohos.accessibility.GesturePath"; import GesturePath from "@ohos.accessibility.GesturePath";
let gesturePath = new GesturePath(100); import GesturePoint from '@ohos.accessibility.GesturePoint';
let gesturePath = new GesturePath.GesturePath(100);
try { try {
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
let gesturePoint = new GesturePoint(100, i * 200); let gesturePoint = new GesturePoint.GesturePoint(100, i * 200);
gesturePath.points.push(gesturePoint); gesturePath.points.push(gesturePoint);
} }
axContext.injectGesture(gesturePath, (err, data) => { axContext.injectGesture(gesturePath, (err, data) => {
...@@ -687,6 +693,8 @@ attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promi ...@@ -687,6 +693,8 @@ attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promi
```ts ```ts
let attributeName = 'name'; let attributeName = 'name';
let attributeValue;
let rootElement;
try { 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');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册