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

!14503 【轻量级 PR】:master: findWindow与getLastWindow示例代码修改:需同步翻译

Merge pull request !14503 from 葛亚芳/N/A
......@@ -23,7 +23,7 @@
| 实例名 | 接口名 | 描述 |
| -------- | -------- | -------- |
| window静态方法 | createWindow(config: Configuration, callback: AsyncCallback\<Window>): void | 创建子窗口。<br/>-`config`:创建窗口时的参数。 |
| window静态方法 | findWindow(id: string, callback: AsyncCallback&lt;Window&gt;): void | 查找`id`所对应的窗口。 |
| window静态方法 | findWindow(name: string): Window | 查找`name`所对应的窗口。 |
| Window | SetUIContent(path: string, callback: AsyncCallback&lt;void&gt;): void | 为当前窗口加载具体页面内容。 |
| Window | moveWindowTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void | 移动当前窗口。 |
| Window | setWindowBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void | 设置窗口的背景色。 |
......@@ -64,14 +64,11 @@
windowClass = data;
});
// 方式二:查找得到子窗口。
window.findWindow("subWindow", (err, data) => {
if (err.code) {
console.error('Failed to find the subWindow. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in finding subWindow. Data: ' + JSON.stringify(data));
windowClass = data;
});
try {
windowClass = window.findWindow('subWindow');
} catch (exception) {
console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
}
```
2. 设置子窗口属性。
......@@ -156,7 +153,7 @@
let mainWindowClass = null;
// 获取主窗口。
window.getLastWindow((err, data) => {
window.getLastWindow(this.context,(err, data) => {
if (err.code) {
console.error('Failed to get the subWindow. Cause: ' + JSON.stringify(err));
return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册