【问题标题】:scrolling not working in ion-view滚动在离子视图中不起作用
【发布时间】:2017-03-11 22:49:15
【问题描述】:

我是 ionic 框架的新手。我试图让我的离子页面设计正确,但我正面临与滚动相关的问题。以下是我的 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 rel="manifest" href="manifest.json">

    <!-- un-comment this code to enable service worker
    <script>
      if ('serviceWorker' in navigator) {
        navigator.serviceWorker.register('service-worker.js')
          .then(() => console.log('service worker installed'))
          .catch(err => console.log('Error', err));
      }
    </script>-->

    <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="js/app.js"></script>
  </head>
  <body ng-app="starter">

    <ion-side-menus>
        <ion-side-menu-content>
            <ion-nav-bar class="bar-positive">
                <ion-nav-buttons side="left">
                    <button class="button button-icon ion-navicon" menu-toggle="left"></button>
                </ion-nav-buttons>
                <ion-nav-buttons side="right">
                    <button class="button button-icon ion-search"></button>
                    <button class="button button-icon ion-ios-email"></button>
                    <button class="button button-icon ion-ios-person"></button>
                </ion-nav-buttons>
                <h1 class="title"> Main Nav bar</h1>
            </ion-nav-bar>
            <ion-header-bar class="bar bar-balanced bar-subheader">
                <button class="button button-icon icon ion-chevron-left"></button>
                <button class="button">ABC</button>
                <h2 class="title">Sub Header</h2>
            </ion-header-bar>
            <ion-footer-bar class="bar bar-footer bar-positive">
                Footer
            </ion-footer-bar>
            <ion-nav-view>
                <ion-view>
                    <ion-content>
                        <h1> Sub header example 1</h1>
                        <h1> Sub header example 2</h1>
                        <h1> Sub header example 3</h1>
                        <h1> Sub header example 4</h1>
                        <h1> Sub header example 5</h1>
                        <h1> Sub header example 6</h1>
                        <h1> Sub header example 7</h1>
                        <h1> Sub header example 8</h1>
                        <h1> Sub header example 9</h1>
                        <h1> Sub header example 10</h1>
                        <h1> Sub header example 11</h1>
                        <h1> Sub header example 12</h1>
                        <h1> Sub header example 13</h1>
                        <h1> Sub header example 14</h1>
                        <h1> Sub header example 15</h1>
                    </ion-content>
                </ion-view>
            </ion-nav-view>
        </ion-side-menu-content>
        <ion-side-menu side="left">
            <ul class="list">
                <li class="item">first
            </ul>
        </ion-side-menu>
    </ion-side-menus>
  </body>
</html>

它显示了 UI,以下是问题:- 1) 有一些间隙,如下图所示:-

2) 有一些内容隐藏在页脚下,如下图所示:-

我不知道,我在使用 ion-content 和 ion-view 时犯了什么错误。 提前致谢。

【问题讨论】:

    标签: html css angularjs ionic-framework


    【解决方案1】:
    <!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 rel="manifest" href="manifest.json">
    
        <!-- un-comment this code to enable service worker
        <script>
          if ('serviceWorker' in navigator) {
            navigator.serviceWorker.register('service-worker.js')
              .then(() => console.log('service worker installed'))
              .catch(err => console.log('Error', err));
          }
        </script>-->
    
        <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="js/app.js"></script>
      </head>
      <body ng-app="starter">
    
        <ion-side-menus>
            <ion-side-menu-content>
                <ion-nav-bar class="bar-positive">
                    <ion-nav-buttons side="left">
                        <button class="button button-icon ion-navicon" menu-toggle="left"></button>
                    </ion-nav-buttons>
                    <ion-nav-buttons side="right">
                        <button class="button button-icon ion-search"></button>
                        <button class="button button-icon ion-ios-email"></button>
                        <button class="button button-icon ion-ios-person"></button>
                    </ion-nav-buttons>
                    <h1 class="title"> Main Nav bar</h1>
                </ion-nav-bar>
                <ion-header-bar class="bar bar-balanced bar-subheader">
                    <button class="button button-icon icon ion-chevron-left"></button>
                    <button class="button">ABC</button>
                    <h2 class="title">Sub Header</h2>
                </ion-header-bar>
                        <ion-content>
                            <h1> Sub header example 1</h1>
                            <h1> Sub header example 2</h1>
                            <h1> Sub header example 3</h1>
                            <h1> Sub header example 4</h1>
                            <h1> Sub header example 5</h1>
                            <h1> Sub header example 6</h1>
                            <h1> Sub header example 7</h1>
                            <h1> Sub header example 8</h1>
                            <h1> Sub header example 9</h1>
                            <h1> Sub header example 10</h1>
                            <h1> Sub header example 11</h1>
                            <h1> Sub header example 12</h1>
                            <h1> Sub header example 13</h1>
                            <h1> Sub header example 14</h1>
                            <h1> Sub header example 15</h1>
                        </ion-content>
    <ion-footer-bar class="bar bar-footer bar-positive">
                    Footer
                </ion-footer-bar>
            </ion-side-menu-content>
            <ion-side-menu side="left">
                <ul class="list">
                    <li class="item">first
                </ul>
            </ion-side-menu>
        </ion-side-menus>
      </body>
    </html>
    

    你可以试试这个细微的改变,这对你有用

    【讨论】:

    • 您能解释一下您所做的更改吗?此外,您能否评论一下,我错过了什么或我做错了什么?
    • 你刚刚在内容上方写了页脚!页脚必须始终在内容之后,而且你使用 并且不需要它,所以我删除了那些
    • 页脚会查看您的内容并防止其滚动。所以页脚必须始终位于底部@ManguSinghRajpurohit
    • 其实页脚不是问题,问题是关于 。删除这两个标签,而不对页脚进行任何更改,使 UI 正常工作。但是为什么我们需要删除 呢? ionic 文档说任何应用程序都需要它来跟踪导航。
    • 使用过一些离子应用程序,但如果没有这个,我可以在任何地方正确导航。你可以尝试一个有导航的应用程序,没有 ion-nav-view
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-09
    相关资源
    最近更新 更多