工具栏的水平滚动不工作的手机

问题描述 投票:5回答:2

enter image description here

我建立离子应用,其中我添加的报头内的工具栏,它有5个按钮来导航。但是当我尝试浏览器的设备代码中的水平滚动正常工作的工具栏,但在实际的设备,它将无法正常工作。有时滚动,有时候不会。下面是相同的代码。

<ion-header>
  <ion-navbar color="light">
    <ion-title>Home</ion-title>
    <ion-buttons end>
      <button ion-button icon-only>
        <ion-icon name="search"></ion-icon>
      </button>
      <button ion-button icon-only>
        <ion-icon name="cart"></ion-icon> 
      </button>
    </ion-buttons>
  </ion-navbar>
  <ion-toolbar color="light">
    <ion-buttons>
      <button ion-button clear>{{'All'|translate}}</button>
    </ion-buttons>
    <ion-buttons *ngFor="let facet of parentCategories">
      <button ion-button [ngClass]=" {'active' : selectedFacet == facet}">{{facet}}
      </button>
      <button ion-button icon-only clear class="accordion" (tap)="getSubFacets(facet);accordion(event)" *ngIf="selectedFacet == facet"><ion-icon name="ios-arrow-down"></ion-icon></button>
    </ion-buttons>
    <div id="sub-category" class="sub-category">
      <ion-buttons *ngFor="let subFacet of childCategories">
        <button ion-button [ngClass]=" {'active' : selectedSubFacet == subFacet}" (tap)="getFilteredProducts('categoryFacet',subFacetMap.get(subFacet), selectedFacet, subFacet)">
          {{subFacet}}</button>
      </ion-buttons>
    </div>
  </ion-toolbar>
</ion-header>

CSS:

.toolbar-content {
     overflow-x: auto;
     white-space: nowrap;
     overflow-y: hidden;
     width: 100%;
     height: 56px;
}
android angular css3 ionic-framework ionic3
2个回答
1
投票

我有同样的问题,我跟着这个样本

CSS:

ion-toolbar.scrollable-segments {
ion-segment {
  display: block;
  overflow-x: scroll;
  white-space: nowrap;

  ion-segment-button.segment-button {
    display: inline-block;
    width: auto;
  }
 }
}

HTML:

<ion-toolbar no-border class="scrollable-segments">
<ion-segment [(ngModel)]="segment">
    <ion-segment-button value="all">
        All
    </ion-segment-button>
    <ion-segment-button value="test">
        Recent
    </ion-segment-button>
    <ion-segment-button value="test2">
        Recent
    </ion-segment-button>
    <ion-segment-button value="test3">
        Recent
    </ion-segment-button>
    <ion-segment-button value="test4">
        Recent
    </ion-segment-button>
    <ion-segment-button value="test5">
        Recent
    </ion-segment-button>
    <ion-segment-button value="test6">
        Recent
    </ion-segment-button>
    <ion-segment-button value="test7">
        Recent
    </ion-segment-button>
</ion-segment>
</ion-toolbar>

参考:qazxsw POI


1
投票

试试这个,它的工作代码,久经考验

HTML:

https://forum.ionicframework.com/t/horizontally-scrolling-sub-header-in-ionic-2/42722/8
© www.soinside.com 2019 - 2024. All rights reserved.