离子含量不滚动 [英] ionic content not scrolling

查看:123
本文介绍了离子含量不滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经经历了很多答案,但没有任何对我有用。我有一个简单的.html文件和离子内容只是不滚动。

 <!DOCTYPE html> 
< html>
< head>
< meta charset =utf-8>
< meta name =viewportcontent =initial-scale = 1,maximum-scale = 1,user-scalable = no,width = device-width>
< title>< / title>
< link href =lib / ionic / css / ionic.css =stylesheet>
< link href =css / style.css =stylesheet>
<! - 如果使用Sass(首先运行gulp sass),然后在下面取消注释并删除CSS包括以上
< link href =css / ionic.app.css =stylesheet >
- >
< script src =js / platformOverrides.js>< / script>

< script src =scripts / angular-resource.min.js>< / script>
<! - ionic / angularjs js - >
< script src =lib / ionic / js / ionic.bundle.js>< / script>
<! - cordova脚本(在开发期间这将是404) - >
< script src =cordova.js>< / script>

< script src =scripts / jquery.min.js>< / script>
< script src =scripts / angular-sanitize.min.js>< / script>
< script src =scripts / angular-ui-router.js>< / script>
< script src =scripts / angular-resource.js>< / script>
< script src =scripts / lodash.min.js>< / script>

< script src =js / app.js>< / script>
< script src =js / appController.js>< / script>
< / head>
< body ng-app =appng-controller =appController>
< ion-pane>
< ion-header-bar class =bar-stable>
< h1 class =title> Ionic Blank Starter< / h1>
< / ion-header-bar>
< ion-view>
< ion-content scroll =true>
< div class =scroll>
< a ng-repeat =项目中的项目class =itemhref =#>
< h2> {{item.name}}< / h2>
< / a>
< / div>
< / ion-content>
< / ion-view>
< / ion-pane>
< / body>
< / html>

以上, $ scope.items 正在从某些web服务中获取。一切都很好,但它不会滚动。
我正在使用Visual studio'Ionic Blank Template',如果这很重要的话。我已经正确配置了Cordova并且所有解决方案都正常工作。

解决方案

删除 class =scroll来自div容器的 scroll =true来自 ion-content 并添加 overflow-scroll =true。所需的类将通过离子添加到元素上。您无需明确添加

 < ion-view> 
< ion-content overflow-scroll =true>
< div class =list>
< a ng-repeat =项目中的项目class =itemhref =#>
< h2> {{item.name}}< / h2>
< / a>
< / div>
< / ion-content>
< / ion-view>

更新:在chrome模拟器中显示可滚动列表的codepen:


I have gone through many answers, but nothing worked for me. I have a simple .html file and ionic content just does not scroll.

<!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">
    -->
    <script src="js/platformOverrides.js"></script>

    <script src="scripts/angular-resource.min.js"></script>
    <!-- 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>

    <script src="scripts/jquery.min.js"></script>
    <script src="scripts/angular-sanitize.min.js"></script>
    <script src="scripts/angular-ui-router.js"></script>
    <script src="scripts/angular-resource.js"></script>
    <script src="scripts/lodash.min.js"></script>

    <script src="js/app.js"></script>
    <script src="js/appController.js"></script>
</head>
<body ng-app="app" ng-controller="appController">
    <ion-pane>
        <ion-header-bar class="bar-stable">
            <h1 class="title">Ionic Blank Starter</h1>
        </ion-header-bar>
        <ion-view>
            <ion-content scroll="true">
                <div class="scroll">
                    <a ng-repeat="item in items" class="item" href="#">
                        <h2>{{item.name}}</h2>
                    </a>
                </div>
            </ion-content>
        </ion-view>
    </ion-pane>
</body>
</html>

Above, $scope.items is being fetched from some webservice. Everything renders fine but it just does not scroll. I am using Visual studio 'Ionic Blank Template' if that matters. I have configured Cordova correctly and rest all solutions just work fine.

解决方案

Remove the class="scroll" from the div container, scroll="true" from ion-content and add overflow-scroll="true" . The required classes will be added by ionic on the elements. You don't need to add that explicitly

<ion-view>
   <ion-content overflow-scroll="true">
        <div class="list">
            <a ng-repeat="item in items" class="item" href="#">
                <h2>{{item.name}}</h2>
            </a>
        </div>
    </ion-content>
</ion-view>

Update: The codepen showing the scrollable list in chrome simulator: http://codepen.io/addi90/full/RaOegM/

这篇关于离子含量不滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆