【问题标题】:ionic2 blank screen after adding new Component添加新组件后ionic2黑屏
【发布时间】:2016-12-20 17:31:50
【问题描述】:

GitHub:https://github.com/eshk12/Parabi/

我正在尝试添加一个新组件调用 Medicine(位于 Pages 目录中)。 我已将其导入app.modules.ts 和app.component.ts, 在我导入它之后。我得到一个带有此错误的空白屏幕:

Unhandled Promise rejection: Failed to load HomePage.html ; Zone: <root> ; Task: Promise.then ; Value: Failed to load HomePage.html undefined

希望你们能帮帮我,谢谢!

【问题讨论】:

    标签: angular ionic2


    【解决方案1】:

    在您的 app.component.ts 中,您需要将该页面添加到数组组件中。

    this.pages = [
      { title: 'עמוד הבית', component: HomePage },
      { title: 'WhatEverTitle', component: Medicine },
     ];
    

    同时导入该页面。看起来您的 Medicine.html 也需要一些重构。

    我建议你使用以下命令生成页面

     ionic g page Medicine
    

    【讨论】:

      【解决方案2】:

      您不必修复您的 app.component,但正如 Savan 所说,您需要查看 Medicine.html。它不应该包含所有常见的文档类型、标题、正文(等等)标签。出于测试目的,我从 Medicine.html 中删除了内容,并添加了此内容

      <ion-content>       
          <p color="dark">Title</p>
      </ion-content>
      

      使用 ionic cli 生成页面、组件和指令。

      https://ionicframework.com/docs/v2/cli/

      【讨论】:

        猜你喜欢
        • 2020-02-01
        • 1970-01-01
        • 2022-07-07
        • 2020-04-09
        • 1970-01-01
        • 2016-08-31
        • 2012-03-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多