我曾见过其他有关此问题的文章,但似乎并未指出我的问题所在。我在控制台等上看不到任何错误,并且浏览器和手机上的行为相同。
代码如下。它确实按预期的方式工作,并加载了另外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>
for .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);
}
[使用event.complete()
时说event.complete() is not a function
,使用事件的每个建议对我来说都不起作用。