#鸿蒙学习大百科#如何获取ApplicationContext?

如何获取ApplicationContext?

HarmonyOS
2024-10-22 14:36:03
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
后知后觉cy
onWindowStageCreate(windowStage: window.WindowStage): void {
  //获取ApplicationContext
  let applicationContext = this.context.getApplicationContext();
  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:37:41


相关问题
#鸿蒙学习大百科#ArkTS如何生成xml?
885浏览 • 1回复 待解决
#鸿蒙学习大百科#如何实现ui优化?
652浏览 • 1回复 待解决