佛山做网站制作公司,为什么有网网站打不开怎么回事啊,深圳做小程序网站开发,株洲高端网站建设一、设置应用主窗口说明
在Stage模型下#xff0c;应用主窗口由UIAbility创建并维护生命周期。在UIAbility的onWindowStageCreate回调中#xff0c;通过WindowStage获取应用主窗口#xff0c;即可对其进行属性设置等操作。还可以在应用配置文件中设置应用主窗口的属性…一、设置应用主窗口说明
在Stage模型下应用主窗口由UIAbility创建并维护生命周期。在UIAbility的onWindowStageCreate回调中通过WindowStage获取应用主窗口即可对其进行属性设置等操作。还可以在应用配置文件中设置应用主窗口的属性如最大窗口宽度maxWindowWidth等。
二、开发步骤
1.获取应用主窗口。
通过getMainWindow接口获取应用主窗口。
2.设置主窗口属性。
可设置主窗口的背景色、亮度值、是否可触等多个属性开发者可根据需要选择对应的接口。本示例以设置“是否可触”属性为例。
3.为主窗口加载对应的目标页面。
通过loadContent接口加载主窗口的目标页面。 鸿蒙OS开发更多内容↓点击HarmonyOS与OpenHarmony技术鸿蒙技术文档开发知识更新库gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md在这。 import UIAbility from ohos.app.ability.UIAbility;export default class EntryAbility extends UIAbility {onWindowStageCreate(windowStage) {// 1.获取应用主窗口。let windowClass null;windowStage.getMainWindow((err, data) {if (err.code) {console.error(Failed to obtain the main window. Cause: JSON.stringify(err));return;}windowClass data;console.info(Succeeded in obtaining the main window. Data: JSON.stringify(data));// 2.设置主窗口属性。以设置是否可触属性为例。let isTouchable true;windowClass.setWindowTouchable(isTouchable, (err) {if (err.code) {console.error(Failed to set the window to be touchable. Cause: JSON.stringify(err));return;}console.info(Succeeded in setting the window to be touchable.);})})// 3.为主窗口加载对应的目标页面。windowStage.loadContent(pages/page2, (err) {if (err.code) {console.error(Failed to load the content. Cause: JSON.stringify(err));return;}console.info(Succeeded in loading the content.);});}
};