#鸿蒙学习大百科#如何为WindowStage的主窗口加载一个页面?

如何为WindowStage的主窗口加载一个页面?


HarmonyOS
2024-10-22 09:14:48
1540浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
风间爱小新V
onWindowStageCreate(windowStage: window.WindowStage): void {

//加载pages/Index页面,该路径需添加到工程的main_pages.json文件中。
  windowStage.loadContent('pages/Index', (err) => {
    if (err.code) {
      hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
      return;
    }
    hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
  });
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
分享
微博
QQ
微信
回复
2024-10-22 22:07:33
相关问题