gpt4 book ai didi

ionic2 - ionic 2 TypeError : self. context.doInfinite 不是函数

转载 作者:行者123 更新时间:2023-12-02 05:16:41 24 4
gpt4 key购买 nike

我正在尝试从服务器加载更多数据,但在控制台中出现错误

zone.js:260 

Uncaught EXCEPTION: Error in build/pages/home/home.html:30:23
ORIGINAL EXCEPTION: TypeError: self.context.doInfinite is not a function
ORIGINAL STACKTRACE:
TypeError: self.context.doInfinite is not a function
at DebugAppView._View_HomePage0._handle_ionInfinite_25_0..

home.ts 有以下代码

import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {Http} from '@angular/http';
import 'rxjs/add/operator/map';
import {JobService} from '../job/job';
import {JobPage} from '../services/JobService';

@Component({
templateUrl: 'build/pages/home/home.html',
providers:[JobService]
})

export class HomePage {
public posts:any = [];
private start:number=0;
constructor(private navCtrl: NavController, public peopleService:PeopleService) {
this.loadPeople();
}

loadPeople() {
return new Promise(resolve => {
this.peopleService.load(this.start)
.then(data => {
for(let kazitz of data) {
this.posts.push(kazitz);
}
resolve(true);
});
});
}

doInfinite(infiniteScroll) {
console.log('doInfinite, start is currently '+this.start);
this.start+=5;
this.loadPeople().then(()=>{
infiniteScroll.complete();
});
}
}

现在,错误提示 doInfinite 不是一个函数,而它是您在上面看到的一个函数,我在应用程序尝试加载更多数据时遇到此错误。在 home.html 中 normal ionic 2加载更多我从 ionic framework docs 中获取的代码

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

任何帮助将不胜感激!

最佳答案

我有同样的问题,只有当我添加 this.doInfinite(); 时它才有效;像这样构造函数():

Constructor(){
this.doInfinite();
}

我不能保证它会起作用,如果不起作用,我深表歉意。老实说,我仍然对此感到困惑。祝你好运!

关于ionic2 - ionic 2 TypeError : self. context.doInfinite 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38813129/

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