HarmonyOS 加载页面时报错Failed to load the content?

报错:Failed to load the content. Cause: {“code”:401}

windowStage.loadContent('pages/NavigationPage', (err, data) => {
  windowStage?.getMainWindowSync()?.setWindowLayoutFullScreen(true); // 界面沉浸式
  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. Data: %{public}s', JSON.stringify(data) ?? '');
});
阅读 539
1 个回答

main\_pages.json 中文件路由缺失,参考如下:

{
  "src": [
  "pages/Index",
  "pages/NavigationPage"
  ]
}

注意:main\_pages.json文件中文件路径不可缺失

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进