【问题标题】:Ionic header covers view content离子标题覆盖视图内容
【发布时间】:2015-04-22 18:43:54
【问题描述】:

我无法在我的应用中容纳标题。 class="has-header" 显然已经过时,我需要帮助寻找替代方案。 谢谢。

如有其他问题,请随时更正。

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>

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

    <!-- your app's js -->
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-route.js"></script>
    <script> 
var Hours = angular.module('Hours', ['ngRoute']);

Hours.config(['$routeProvider',
  function($routeProvider) {
    $routeProvider.
      when('/', {
        templateUrl: '1.html',
    }).
      when('/dininghalls', {
        templateUrl: '2.html',
    }).
      when('/fitnesscenters', {
        templateUrl: '3.html'
      }).
      when('/officehours', {
        templateUrl: '4.html'
      }).
      otherwise({
        redirectTo: '/'
      });
}]);
 </script>
  </head>
  <body ng-app="Hours">
        <div ng-view=""></div>
  </body>
</html>

1.html:

<ion-header-bar align-title="left" class="bar-positive">
<div class="bar bar-header bar-stable">
  <h1 class="title">Hours</h1>
</div>
</ion-header-bar>


<ion-content>
<a href="#/4" class="button button-block button-positive">
Hours
</a>
<a href="#/2" class="button button-block button-positive">
Halls
</a>
<a href="#/3" class="button button-block button-positive">
Fitness 
</a>
</ion-content>

【问题讨论】:

  • 将 class="has-header" 添加到您的容器中
  • 谢谢,但我特别指出不再支持使用 class="has-header"。还有其他想法吗?
  • 为什么在 ion-header-bar 中有一个 .header bar?

标签: angularjs ionic-framework web-applications angular-ui-router


【解决方案1】:

您需要将&lt;ion-content&gt; 更改为&lt;ion-content class="has-header"&gt; ........

【讨论】:

    【解决方案2】:

    has-header="true" 添加到您的离子内容中(看起来文档中可能缺少该内容?)。您的&lt;ion-header-bar&gt; 中也不应该需要class="header-bar"

    更新: 您需要在模块 Hours 中注入 ionic 作为依赖项。

    【讨论】:

    • 嘿,我知道已经有一段时间了,但我真的很忙,只是尝试了你所说的。它仍然不起作用。还有其他建议吗?
    • 我删除了 class= "header-bar" 并将 has-header="true" 添加到我的 ion 内容中,但仍然没有任何效果,请帮助
    • 好吧,为有史以来最令人沮丧的答案做好准备:您需要在模块Hours 中注入ionic 作为依赖项。是的,这是必要的——我开始了一个空白项目,并在有或没有这种依赖的情况下进行了尝试,这绝对是必要的——必须查看源代码才能找出原因,但它肯定是。
    • 如果这没有解决您的问题,请告诉我。如果是,请接受它作为答案!
    • 所以这意味着 'ionic' 会紧挨着 'ngRoute' 对吗?
    猜你喜欢
    • 2015-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-12
    相关资源
    最近更新 更多