gpt4 book ai didi

angular - ionic 4 infinite scroll 只工作一次

转载 作者:行者123 更新时间:2023-12-04 17:31:22 25 4
gpt4 key购买 nike

我看过其他关于此问题的帖子,但似乎没有说明我的问题是什么。我没有在控制台等上看到任何错误,并且在浏览器和手机上的行为是相同的。

代码如下。它确实第一次按预期工作并加载了另外 5 个对象。但后来我没有看到它再次被解雇

<ion-content fullscreen>
<div class="full-screen-bg">

<div style="background-color: #181828;padding:10px">
<ion-row *ngFor="let gal of core.gallery; let i=index">

<ion-col *ngIf="i%2 == 0 && core.gallery[i] != undefined" class="ion-text-center ion-padding" style="padding-top:0px !important">
<img *ngIf="core.gallery[i].type == 'image'" src="{{core.gallery[i].link}}" (click)="zoomImage(i)">
<iframe *ngIf="core.gallery[i].type == 'video'" style="width: 100%" [src]="getVideoUrl(core.gallery[i].link)" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</ion-col>
<ion-col *ngIf="i%2 == 0 && core.gallery[i+1] != undefined" style="padding-left:0px !important;padding-top:0px !important" class="ion-text-center ion-padding">
<img *ngIf="core.gallery[i+1].type == 'image'" src="{{core.gallery[i+1].link}}" (click)="zoomImage(i+1)">
<iframe *ngIf="core.gallery[i+1].type == 'video'" style="width: 100%" [src]="getVideoUrl(core.gallery[i+1].link)" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</ion-col>

</ion-row>
</div>
</div>

<ion-infinite-scroll #infiniteScroll (ionInfinite)="loadData($event)">
<ion-infinite-scroll-content
loadingSpinner="bubbles"
loadingText="Loading more data...">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
</ion-content>

对于.ts

import { IonInfiniteScroll } from '@ionic/angular';

....
@ViewChild(IonInfiniteScroll) infiniteScroll: IonInfiniteScroll;

loadData(event) {
setTimeout(async() => {

let resp = await this.sgSvc.getGalleryPaged(this.anchorKey)
console.log("new anchor key:" + JSON.stringify(resp[0].key))
this.anchorKey = resp[0].key
var galleryKeys = Object.keys(resp)

for(let galleryKey of galleryKeys){
var galleryObj = resp[galleryKey]
//console.log(galleryObj._name + " " + galleryObj._link)

if(this.showPhotos == false && galleryObj._type == 'image')
continue

if(this.showVideos == false && galleryObj._type == 'video')
continue

var glry:Gallery = new Gallery(galleryKey, galleryObj._name, galleryObj._type, galleryObj._link, galleryObj._date, galleryObj._desc)
this.core.gallery.push(glry)
}

console.log('Done');
event.target.complete();
}, 500);
}

最佳答案

同样的问题发生在我开发的一个页面上。
在评论“overflow-y: scroll;”之后,我在同一组件的 scss 中使用了以下样式
它开始运作良好。这很奇怪。我花了 3 个小时才弄明白:)

ion-grid,
ion-row {
height: 100%;
overflow-y: scroll;
}

关于angular - ionic 4 infinite scroll 只工作一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59345607/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com