【问题标题】:Ionic simple app not working on mobile离子简单的应用程序无法在移动设备上运行
【发布时间】:2017-02-16 11:03:11
【问题描述】:

我正在使用 Ionic 开发一个非常简单的应用程序,以便学习如何使用该工具。它意味着选项卡,我按照官方文档中给出的选项卡教程进行操作。它在我的浏览器上运行良好,但在我的 Android 设备上编译时出现“死屏”。

这是我的简化代码:

索引.html

<html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title>Home</title>
    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
  </head>

  <body>
    <ion-nav-bar class="bar-positive">
      <ion-nav-back-button>
      </ion-nav-back-button>
    </ion-nav-bar>

    <ion-nav-view></ion-nav-view>

    <script id="templates/tabs.html" type="text/ng-template">
      <ion-tabs class="tabs-icon-top tabs-positive">
        <ion-tab title="Home" icon="ion-home" href="#/tab/home">
          <ion-nav-view name="home-tab"></ion-nav-view>
        </ion-tab>
      </ion-tabs>
    </script>

    <script id="templates/home.html" type="text/ng-template">
      <ion-view view-title="Menu Principal">
        <ion-content class="padding">
          <a href="#/tab/sceneTest"><img class="popphoto" src="b_menu1.png"></a>
        </ion-content>
      </ion-view>
    </script>

  </body>

JS部分:

  <script>
  angular.module('ionicApp', ['ionic'])

  .config(function($stateProvider, $urlRouterProvider) {

    $stateProvider
      .state('tabs', {
        url: "/tab",
        abstract: true,
        templateUrl: "templates/tabs.html"
      })

      .state('tabs.home', {
        url: "/home",
        views: {
          'home-tab': {
            templateUrl: "templates/home.html",
            controller: 'HomeTabCtrl'
          }
        }
      })

      .state('tabs.sceneTest', {
        url: "/sceneTest",
         views: {
          'home-tab': {
            templateUrl: "sceneTest.html"
          }
        }
      })

     $urlRouterProvider.otherwise("/tab/home");
  })

  .controller('HomeTabCtrl', function($scope) {
    console.log('HomeTabCtrl');
  });
  </script>
</html>

“sceneTest.html”文件与 index.html 位于同一路径。我不认为它会导致错误,因为到目前为止它的内容非常简单(只是一个包裹在 ion-view 中的文本)。

您知道是什么原因导致手机出现黑屏吗?我听说这可能是因为我没有正确处理一些内含物。但是,我对 Ionic 和 Angular 都很陌生(jQuery 粉丝试图打开他的思路),所以很难找到确切的原因。

非常感谢您的帮助。

【问题讨论】:

    标签: javascript android html angularjs ionic-framework


    【解决方案1】:

    调用应用www文件夹中的文件

    走错路了

    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
    

    好方法

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多