am使用 ionic 3 和 WordPress REST API
正在尝试使用代码
来刷新功能的console.log
。 doRefresh(refresher) {
console.log('Begin async operation', refresher);
setTimeout(() => {
console.log('Async operation has ended');
refresher.complete();
}, 2000);
}
任何帮助将不胜感激。谢谢
您对使用刷新组件是正确的。dorefresh方法是由视图调用的,我们获取数据,一旦完成,我们将在Refresher对象上调用完整方法。
.ts
import { Storage } from '@ionic/storage';
items: any;
constructor(public navCtrl: NavController, public storage: Storage) {
this.doRefresh();
}
doRefresh(refresher){
this.storage.get('myStore').then((data) => {
this.items = data;
if(refresher)
refresher.complete();
});
}
html
<ion-refresher (ionRefresh)="doRefresh($event)">
<ion-refresher-content
pullingText="Pull to refresh"
pullingIcon="arrow-dropdown"
refreshingSpinner="circles"
refreshingText="..fetching">
</ion-refresher-content>
</ion-refresher>