提交 cb4606f0 编写于 作者: Z zhengjiangliang

doc文档示例代码整改

Change-Id: I575b55db46ebae64b56392192773eab0ff73ce08
Signed-off-by: Nzhengjiangliang <zhengjiangliang@huawei.com>
上级 edf2468e
......@@ -94,7 +94,7 @@ try {
displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
};
}
```
## display.getAllDisplays<sup>9+</sup>
......@@ -204,25 +204,24 @@ hasPrivateWindow(displayId: number): boolean
let displayClass = null;
try {
displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
return;
};
let ret = undefined;
try {
ret = display.hasPrivateWindow(displayClass.id);
let ret = undefined;
try {
ret = display.hasPrivateWindow(displayClass.id);
} catch (exception) {
console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception));
}
if (ret == undefined) {
console.log("Failed to check has privateWindow or not.");
}
if (ret) {
console.log("There has privateWindow.");
} else if (!ret) {
console.log("There has no privateWindow.");
}
} catch (exception) {
console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception));
};
if (ret == undefined) {
console.log("Failed to check has privateWindow or not.");
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
if (ret) {
console.log("There has privateWindow.");
} else if (!ret) {
console.log("There has no privateWindow.");
};
```
## display.on('add'|'remove'|'change')
......@@ -250,7 +249,7 @@ try {
display.on("add", callback);
} catch (exception) {
console.error('Failed to register callback. Code: ' + JSON.stringify(exception));
};
}
```
## display.off('add'|'remove'|'change')
......@@ -275,7 +274,7 @@ try {
display.off("remove");
} catch (exception) {
console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception));
};
}
```
## display.getDefaultDisplay<sup>(deprecated)</sup>
......@@ -450,17 +449,17 @@ getCutoutInfo(callback: AsyncCallback&lt;CutoutInfo&gt;): void
let displayClass = null;
try {
displayClass = display.getDefaultDisplaySync();
displayClass.getCutoutInfo((err, data) => {
if (err.code) {
console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
};
displayClass.getCutoutInfo((err, data) => {
if (err.code) {
console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data));
});
}
```
### getCutoutInfo<sup>9+</sup>
getCutoutInfo(): Promise&lt;CutoutInfo&gt;
......@@ -489,12 +488,14 @@ getCutoutInfo(): Promise&lt;CutoutInfo&gt;
let displayClass = null;
try {
displayClass = display.getDefaultDisplaySync();
let promise = displayClass.getCutoutInfo();
promise.then((data) => {
console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data));
}).catch((err) => {
console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
};
let promise = displayClass.getCutoutInfo();
promise.then((data) => {
console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data));
});
}
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册