离子垂直滚动在选项卡式内容中不起作用

lsmepo6l  于 2022-10-24  发布在  Angular
关注(0)|答案(3)|浏览(185)

我已经为内容设置了一系列带有ion-view的标签。内容在每个选项卡式路径中都可以正确显示,但选项卡式内容不会垂直滚动,并且列表会脱离页面,使其无法访问。选项卡不应该滚动吗?文件显示,默认情况下,离子内容的滚动功能应该是打开的。
索引

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
  6. <title></title>
  7. <!-- Application Styles -->
  8. <link href="css/ionic.app.css" rel="stylesheet">
  9. <!-- Ionic Angular Scripts -->
  10. <script src="lib/ionic/js/ionic.bundle.js"></script>
  11. <script src="lib/ionic/js/angular/angular-resource.js"></script>
  12. <!-- Cordova Scripts -->
  13. <script src="cordova.js"></script>
  14. <!-- Application Scripts -->
  15. <script src="js/app.js"></script>
  16. <script src="js/app-configuration.js"></script>
  17. <script src="js/app-interceptor.js"></script>
  18. <script src="js/app-route.js"></script>
  19. <script src="js/app-route-controller.js"></script>
  20. <script src="js/app-resource.js"></script>
  21. <script src="js/app-service.js"></script>
  22. </head>
  23. <body ng-app="eventApp">
  24. <ion-nav-view></ion-nav-view>
  25. </body>
  26. </html>

Jmeter 板视图-/ Jmeter 板

  1. <ion-side-menus>
  2. <ion-side-menu-content>
  3. <ion-nav-bar class="bar-light">
  4. <ion-nav-back-button class="button-clear">
  5. <i class="ion-chevron-left"></i>&nbsp; Back
  6. </ion-nav-back-button>
  7. <ion-nav-buttons side="left">
  8. <button class="button button-icon button-clear ion-navicon" menu-toggle="left"></button>
  9. </ion-nav-buttons>
  10. </ion-nav-bar>
  11. <ion-nav-view></ion-nav-view>
  12. </ion-side-menu-content>
  13. <ion-side-menu side="left">
  14. <ion-header-bar class="bar-light"></ion-header-bar>
  15. <ion-content>
  16. <ion-list class="list">
  17. <ion-item href="#" ui-sref="dashboard.index" class="item-icon-left" menu-close>
  18. <i class="icon ion-map"></i>&nbsp; Map
  19. </ion-item>
  20. <ion-item href="#" ui-sref="dashboard.profile.index" class="item-icon-left" menu-close>
  21. <i class="icon ion-android-person"></i>&nbsp; User Profile
  22. </ion-item>
  23. <ion-item href="#" ui-sref="dashboard.event.index" class="item-icon-left" menu-close>
  24. <i class="icon ion-android-calendar"></i>&nbsp; Events
  25. </ion-item>
  26. </ion-list>
  27. </ion-content>
  28. </ion-side-menu>
  29. </ion-side-menus>

选项卡内部视图-/ Jmeter 板/事件/列表

  1. <ion-view view-title="" id="pk-event" hide-back-button="true">
  2. <ion-tabs class="tabs-positive">
  3. <ion-tab title="Current" ui-sref="dashboard.event.index">
  4. <ion-nav-view name="current-tab"></ion-nav-view>
  5. </ion-tab>
  6. <ion-tab title="Upcoming" ui-sref="dashboard.event.upcoming">
  7. <ion-nav-view name="upcoming-tab"></ion-nav-view>
  8. </ion-tab>
  9. <ion-tab title="Past" ui-sref="dashboard.event.past">
  10. <ion-nav-view name="past-tab"></ion-nav-view>
  11. </ion-tab>
  12. </ion-tabs>
  13. </ion-view>

选项卡子视图-/ Jmeter 板/事件/列表/当前

  1. <ion-view title="">
  2. <ion-content>
  3. <ion-list show-delete="showDelete"
  4. show-reorder="showReorder"
  5. can-swipe="canSwipe">
  6. <div class="item item-divider">
  7. Current Events
  8. </div>
  9. <div ng-repeat="event in events">
  10. <div>Date: {{event.dates[0] | date}}</div>
  11. <br>
  12. <h2>{{event.name}}</h2>
  13. <p>Event Address: {{event.address}}</p>
  14. <p>{{event.note}}</p>
  15. </ion-item>
  16. </div>
  17. </ion-list>
  18. </ion-content>
  19. </ion-view>
rhfm7lfc

rhfm7lfc1#

我非常确定父对象应该在您的index.html文件中,并且应该有一个

  1. <ion-nav-view>
  2. </ion-nav-view>
  3. <ion-tabs>
  4. </ion-tabs>

然后你的

  1. <ion-view>
  2. <ion-content>
  3. </ion-content>
  4. <ion-view>

当您发送到某个州时,将填充ion-NAV-view,并且您的选项卡将保留在该视图下,并且不会滚动,而视图中的内容将会滚动。您也可以将选项卡放在ion-view中的ion-content下,但是,如果您采用这种方法并且必须复制布线逻辑,则需要将它们放置在每个状态下。这里有一个例子,我使用了一个离子视图,它持有一个幻灯片框,其中一张幻灯片带有标签,其中包含离子内容。以下是我删除的一个示例中的代码。
Html:

  1. <html ng-app="ionicApp">
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
  5. <title>Side Menus</title>
  6. <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
  7. <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
  8. </head>
  9. <body ng-controller="MainCtrl">
  10. <ion-nav-view></ion-nav-view>
  11. <ion-tabs class="tabs-positive tabs-icon-only">
  12. <ion-tab title="Home" icon-on="ion-ios-filing" icon-off="ion-ios-filing-outline">
  13. <!-- Tab 1 content -->
  14. </ion-tab>
  15. <ion-tab title="About" icon-on="ion-ios-clock" icon-off="ion-ios-clock-outline">
  16. <!-- Tab 2 content -->
  17. </ion-tab>
  18. <ion-tab title="Settings" icon-on="ion-ios-gear" icon-off="ion-ios-gear-outline">
  19. <!-- Tab 3 content -->
  20. </ion-tab>
  21. </ion-tabs>
  22. <script id="templates/event-menu.html" type="text/ng-template">
  23. <ion-side-menus enable-menu-with-back-views="false">
  24. <ion-side-menu-content>
  25. <ion-nav-bar class="bar-positive">
  26. <ion-nav-back-button>
  27. </ion-nav-back-button>
  28. <ion-nav-buttons side="left">
  29. <button class="button button-icon button-clear ion-navicon" menu-toggle="left">
  30. </button>
  31. </ion-nav-buttons>
  32. </ion-nav-bar>
  33. <ion-nav-view name="menuContent"></ion-nav-view>
  34. </ion-side-menu-content>
  35. <ion-side-menu side="left">
  36. <ion-header-bar class="bar-assertive">
  37. <h1 class="title">Left Menu</h1>
  38. </ion-header-bar>
  39. <ion-content>
  40. <ul class="list">
  41. <!-- Note each link has the 'menu-close' attribute so the menu auto closes when clicking on one of these links -->
  42. <a href="#/event/check-in" class="item" menu-close>Check-in</a>
  43. <a href="#/event/attendees" class="item" menu-close>Attendees</a>
  44. </ul>
  45. </ion-content>
  46. </ion-side-menu>
  47. </ion-side-menus>
  48. </script>
  49. <script id="templates/home.html" type="text/ng-template">
  50. <ion-view view-title="Welcome">
  51. <ion-content class="padding">
  52. <p>Swipe to the right to reveal the left menu.</p>
  53. <p>(On desktop click and drag from left to right)</p>
  54. </ion-content>
  55. </ion-view>
  56. </script>
  57. <script id="templates/check-in.html" type="text/ng-template">
  58. <ion-view view-title="Event Check-in">
  59. <ion-content>
  60. <form class="list" ng-show="showForm">
  61. <div class="item item-divider">
  62. Attendee Info
  63. </div>
  64. <label class="item item-input">
  65. <input type="text" placeholder="First Name" ng-model="attendee.firstname">
  66. </label>
  67. <label class="item item-input">
  68. <input type="text" placeholder="Last Name" ng-model="attendee.lastname">
  69. </label>
  70. <div class="item item-divider">
  71. Shirt Size
  72. </div>
  73. <ion-radio ng-repeat="shirtSize in shirtSizes"
  74. ng-value="shirtSize.value"
  75. ng-model="attendee.shirtSize">
  76. {{ shirtSize.text }}
  77. </ion-radio>
  78. <div class="item item-divider">
  79. Lunch
  80. </div>
  81. <ion-toggle ng-model="attendee.vegetarian">
  82. Vegetarian
  83. </ion-toggle>
  84. <div class="padding">
  85. <button class="button button-block" ng-click="submit()">Checkin</button>
  86. </div>
  87. </form>
  88. <div ng-hide="showForm">
  89. <pre ng-bind="attendee | json"></pre>
  90. <a href="#/event/attendees">View attendees</a>
  91. </div>
  92. </ion-content>
  93. </ion-view>
  94. </script>
  95. <script id="templates/attendees.html" type="text/ng-template">
  96. <ion-view view-title="Event Attendees">
  97. <ion-content>
  98. <div class="list">
  99. <ion-toggle ng-repeat="attendee in attendees | orderBy:'firstname' | orderBy:'lastname'"
  100. ng-model="attendee.arrived"
  101. ng-change="arrivedChange(attendee)">
  102. {{ attendee.firstname }}
  103. {{ attendee.lastname }}
  104. </ion-toggle>
  105. <div class="item item-divider">
  106. Activity
  107. </div>
  108. <div class="item" ng-repeat="msg in activity">
  109. {{ msg }}
  110. </div>
  111. </div>
  112. </ion-content>
  113. </ion-view>
  114. </script>
  115. </body>
  116. </html>

JS:

  1. angular.module('ionicApp', ['ionic'])
  2. .config(function($stateProvider, $urlRouterProvider) {
  3. $stateProvider
  4. .state('eventmenu', {
  5. url: "/event",
  6. abstract: true,
  7. templateUrl: "templates/event-menu.html"
  8. })
  9. .state('eventmenu.home', {
  10. url: "/home",
  11. views: {
  12. 'menuContent' :{
  13. templateUrl: "templates/home.html"
  14. }
  15. }
  16. })
  17. .state('eventmenu.checkin', {
  18. url: "/check-in",
  19. views: {
  20. 'menuContent' :{
  21. templateUrl: "templates/check-in.html",
  22. controller: "CheckinCtrl"
  23. }
  24. }
  25. })
  26. .state('eventmenu.attendees', {
  27. url: "/attendees",
  28. views: {
  29. 'menuContent' :{
  30. templateUrl: "templates/attendees.html",
  31. controller: "AttendeesCtrl"
  32. }
  33. }
  34. })
  35. $urlRouterProvider.otherwise("/event/home");
  36. })
  37. .controller('MainCtrl', function($scope, $ionicSideMenuDelegate) {
  38. $scope.attendees = [
  39. { firstname: 'Nicolas', lastname: 'Cage' },
  40. { firstname: 'Jean-Claude', lastname: 'Van Damme' },
  41. { firstname: 'Keanu', lastname: 'Reeves' },
  42. { firstname: 'Steven', lastname: 'Seagal' }
  43. ];
  44. $scope.toggleLeft = function() {
  45. $ionicSideMenuDelegate.toggleLeft();
  46. };
  47. })
  48. .controller('CheckinCtrl', function($scope) {
  49. $scope.showForm = true;
  50. $scope.shirtSizes = [
  51. { text: 'Large', value: 'L' },
  52. { text: 'Medium', value: 'M' },
  53. { text: 'Small', value: 'S' }
  54. ];
  55. $scope.attendee = {};
  56. $scope.submit = function() {
  57. if(!$scope.attendee.firstname) {
  58. alert('Info required');
  59. return;
  60. }
  61. $scope.showForm = false;
  62. $scope.attendees.push($scope.attendee);
  63. };
  64. })
  65. .controller('AttendeesCtrl', function($scope) {
  66. $scope.activity = [];
  67. $scope.arrivedChange = function(attendee) {
  68. var msg = attendee.firstname + ' ' + attendee.lastname;
  69. msg += (!attendee.arrived ? ' has arrived, ' : ' just left, ');
  70. msg += new Date().getMilliseconds();
  71. $scope.activity.push(msg);
  72. if($scope.activity.length > 3) {
  73. $scope.activity.splice(0, 1);
  74. }
  75. };
  76. });
展开查看全部
5lhxktic

5lhxktic2#

1.如果您还想使用离子含量,请尽量增加高度

  1. <ion-content height="500"> //it may be possible to use height="100%"

2.尝试使用<ion-scroll direction="y"> instead of <ion-content>
选项卡子视图-/ Jmeter 板/事件/列表/当前

  1. <ion-view title="">
  2. <ion-scroll direction="y> <!-- use ion-scroll instead-->
  3. <ion-list show-delete="showDelete"
  4. show-reorder="showReorder"
  5. can-swipe="canSwipe">
  6. <div class="item item-divider">
  7. Current Events
  8. </div>
  9. <div ng-repeat="event in events">
  10. <ion-item>
  11. <div>Date: {{event.dates[0] | date}}</div>
  12. <br>
  13. <h2>{{event.name}}</h2>
  14. <p>Event Address: {{event.address}}</p>
  15. <p>{{event.note}}</p>
  16. </ion-item>
  17. </div>
  18. </ion-list>
  19. </ion-scroll>
  20. </ion-view>
展开查看全部
bvk5enib

bvk5enib3#

我也遇到过类似的问题。我只是这样做了:
<ion-content scroll="true">.....</ion-content>
一切都很顺利。希望能有所帮助。

相关问题