离子内容不滚动 [英] ionic content not scrolling
问题描述
我经历了很多答案,但没有一个对我有用.我有一个简单的 .html 文件,离子内容只是不滚动.
<头><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"><!-- 如果使用 Sass(首先运行 gulp sass),然后取消下面的注释并删除上面的 CSS<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 脚本(在开发过程中这将是 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>头部><body ng-app="app" ng-controller="appController"><离子窗格><ion-header-bar class="bar-stable"><h1 class="title">Ionic Blank Starter</h1></ion-header-bar><离子视图><ion-content scroll="true"><div class="scroll"><a ng-repeat="item in items" class="item" href="#"><h2>{{item.name}}</h2></a>
</离子含量></ion-view></ion-pane></html>
上面,$scope.items
正在从某个网络服务中获取.一切都很好,但它只是不滚动.如果重要的话,我正在使用 Visual Studio 'Ionic Blank Template'.我已经正确配置了 Cordova,其余的所有解决方案都可以正常工作.
从 div 容器中删除 class="scroll"
,从 scroll="true"
code>ion-content 并添加 overflow-scroll="true"
.所需的类将通过 ionic 添加到元素上.您不需要明确添加
<ion-content overflow-scroll="true"><div class="list"><a ng-repeat="item in items" class="item" href="#"><h2>{{item.name}}</h2></a>
</离子含量></ion-view>
更新:在 chrome 模拟器中显示可滚动列表的代码笔:
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屋!