组件内列表的滚动不起作用
Scroll of a list inside a component does not work
我创建了一个通用列表(组件)以在我的所有页面中使用,但滚动不起作用。
主页面:
<ion-header>
<app-generic-menu [leftMenu]="'left-menu'"
[rightMenu]="'client-menu'"
[isSelectionMode]="isSelectionMode()"
[pageTitle]="'Clientes'"
[topicReload]="'client-list:reload'"
(valueToSearch)="inputShearchBox = $event">
</app-generic-menu>
</ion-header>
<ion-content>
<app-generic-list [array]="arrayClients"
[label1Row1]="'id'"
[label2Row1]="'social_reason_name'"
[label1Row2]="'document'"
[pageToGo]="'/new-client'"
[icon]="'person'"
[pipe]="documentPipe"
[selectedObjects]="selectedClients"
(selectedObjectsEvent)="selectedClients = $event">
</app-generic-list>
</ion-content>
这是我的组件(应用程序通用列表):
<ion-list>
<ion-item *ngFor="let x of array; trackBy: trackByFn" (press)="onLongPressObject(x)"
(tap)="isSelectionMode() ? onLongPressObject(x) : showObject(x)"
[ngClass]="{'selected-background': selectedObjects.indexOf(x) >= 0}">
<ion-icon name="checkmark-circle" slot="start" class="floating-icon" style="color: #43A047;"
*ngIf="selectedObjects.indexOf(x) >= 0"></ion-icon>
<ion-icon slot="start" name="{{[icon]}}"></ion-icon>
<ion-grid>
<ion-row>
<ion-label>{{x[label1Row1]}} - {{x[label2Row1]}}</ion-label>
</ion-row>
<ion-row>
<p>{{x[label1Row2] | genericPipe : pipe:[]}}</p>
</ion-row>
</ion-grid>
</ion-item>
</ion-list>
<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button [routerLink]="pageToGo" routerDirection="forward">
<ion-icon name="add"></ion-icon>
</ion-fab-button>
</ion-fab>
我在数组中有 10 个元素,但只出现了 9 个,我无法滚动页面,这只发生在组件上,ion-content
中有一个普通列表,滚动有效。
在子组件中滚动是否需要任何配置?
应用的外观如下:
还有一项,但我无法滚动。
您需要在列表中添加 margin-bottom 以考虑选项卡的大小 section/footer,并且您可能需要为 ion-content 手动添加滚动行为,参考:https://ionicframework.com/docs/api/content#usage
<ion-content[scrollY]="true"></ion-content>
我创建了一个通用列表(组件)以在我的所有页面中使用,但滚动不起作用。
主页面:
<ion-header>
<app-generic-menu [leftMenu]="'left-menu'"
[rightMenu]="'client-menu'"
[isSelectionMode]="isSelectionMode()"
[pageTitle]="'Clientes'"
[topicReload]="'client-list:reload'"
(valueToSearch)="inputShearchBox = $event">
</app-generic-menu>
</ion-header>
<ion-content>
<app-generic-list [array]="arrayClients"
[label1Row1]="'id'"
[label2Row1]="'social_reason_name'"
[label1Row2]="'document'"
[pageToGo]="'/new-client'"
[icon]="'person'"
[pipe]="documentPipe"
[selectedObjects]="selectedClients"
(selectedObjectsEvent)="selectedClients = $event">
</app-generic-list>
</ion-content>
这是我的组件(应用程序通用列表):
<ion-list>
<ion-item *ngFor="let x of array; trackBy: trackByFn" (press)="onLongPressObject(x)"
(tap)="isSelectionMode() ? onLongPressObject(x) : showObject(x)"
[ngClass]="{'selected-background': selectedObjects.indexOf(x) >= 0}">
<ion-icon name="checkmark-circle" slot="start" class="floating-icon" style="color: #43A047;"
*ngIf="selectedObjects.indexOf(x) >= 0"></ion-icon>
<ion-icon slot="start" name="{{[icon]}}"></ion-icon>
<ion-grid>
<ion-row>
<ion-label>{{x[label1Row1]}} - {{x[label2Row1]}}</ion-label>
</ion-row>
<ion-row>
<p>{{x[label1Row2] | genericPipe : pipe:[]}}</p>
</ion-row>
</ion-grid>
</ion-item>
</ion-list>
<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button [routerLink]="pageToGo" routerDirection="forward">
<ion-icon name="add"></ion-icon>
</ion-fab-button>
</ion-fab>
我在数组中有 10 个元素,但只出现了 9 个,我无法滚动页面,这只发生在组件上,ion-content
中有一个普通列表,滚动有效。
在子组件中滚动是否需要任何配置?
应用的外观如下:
还有一项,但我无法滚动。
您需要在列表中添加 margin-bottom 以考虑选项卡的大小 section/footer,并且您可能需要为 ion-content 手动添加滚动行为,参考:https://ionicframework.com/docs/api/content#usage
<ion-content[scrollY]="true"></ion-content>