【问题标题】:Ionic serve results in a blank page离子服务导致空白页面
【发布时间】:2015-03-28 08:00:43
【问题描述】:

我最近偶然发现了一个烦人的问题,但不知道是什么原因。我正在开发一个离子混合应用程序,从昨天开始一切正常:我能够在我的安卓手机上部署它,我可以在我的浏览器上调试它。今天我打开我的项目,启动ionic serve,浏览器以空白屏幕迎接我。

我得到了地址:localhost:8100/,但它确实应该是 localhost:8100/#/app/sessions

控制台日志和网络日志都没有报告错误。 这是index.html页面的源代码:

    <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="lib/angular/angular.min.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/services.js"></script>
  </head>

  <body ng-app="starter">
    <ion-nav-view></ion-nav-view>
  </body>
</html>

我尝试开始一个新的 ionic 项目,但结果是一样的:我得到一个空白页。 我已将ionic serve 地址设置为 localhost;我尝试加载所有角度和离子模块,但无济于事。你有什么建议吗?

【问题讨论】:

  • 输入ionic serve -c转储控制台日志以查看是否有错误,也可以在浏览器调试器中打开控制台查找错误
  • 如果包含ionic.bundle.js,则不需要手动包含角度。
  • 您能否尝试使用浏览器中可用的开发人员工具,您很可能会在那边看到错误日志,因为离子服务向您显示空白页面。
  • 我可以看看你的 app.js 吗?

标签: ionic


【解决方案1】:

经过仔细检查,我发现了这个错误(我浏览了日志):

"Error: [$injector:modulerr] Failed to instantiate module starter due to:
[$injector:modulerr] Failed to instantiate module starter.controllers due to:
[$injector:modulerr] Failed to instantiate module starter.services due to:
[$injector:modulerr] Failed to instantiate module ngResource due to:

**[$injector:nomod] Module 'ngResource' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.**

我不太确定为什么,但是 angular 找不到 ngResource 模块。快速检查显示拼写并不是真正的问题。

出于某种原因(我仍在调查中)发布应用程序破坏了 angular-resource.js 并且生成的 .min 缺少代码。 无论如何,当我尝试重新加载整个内容时,我正在加载 ngResource 版本 1.3.15 和 angular.js 版本 1.3.14,使它们无法正常工作。 所以,我没有通过计算机科学 101:“总是检查版本”。

我已将所有版本设置为 1.3.15,并且一切正常。

【讨论】:

    【解决方案2】:

    不管怎样,我们遇到了一个非常相似的问题:ionic serve -c 没有负面行为,没有错误输出,只是加载了一个空白屏幕。

    我们的问题是有一个“!”在工作目录的完整路径中。

    将工作目录更改为不带“!”的路径解决了这个问题。

    Original solution here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-17
      • 1970-01-01
      相关资源
      最近更新 更多