angular - Ionic 4 Refresher 没有传入 refresher 对象,所以我无法完成它
问题描述
尝试完成复习时,出现错误
TypeError: refresher.complete 不是一个函数。
.html:
<ion-refresher #refresherRef slot="fixed" (ionRefresh)="load($event)">
<ion-refresher-content
pullingIcon="arrow-dropdown"
pullingText="Pull to refresh"
refreshingSpinner="circles"
refreshingText="Refreshing...">
</ion-refresher-content>
</ion-refresher>
.ts
load(refresher) {
let postData = new FormData();
postData.append('user_id', this.userData.userId);
this.authService.postData(postData, "is_verified_or_not.php").then((result) => {
this.responseData = result;
this.success = this.responseData.success;
if (this.success == 1) {
refresher.complete();
let userDeatil = this.responseData.users_details;
for (let data1 of userDeatil) {
}
} else {
this.message = this.responseData.message;
refresher.complete();
this.showToast(this.message);
}
}, (err) => {
refresher.complete();
console.log("Error", err);
});
}
我试过了:
@ViewChild("refresherRef") refresherRef: Refresher;
load(refresher: Refresher) {
this.refresherRef.complete();
}
但这给了我一个错误@ViewChild("refresherRef")
预期 2 个参数,但得到 1.ts(2554) core.d.ts(8436, 47):未提供“opts”的参数。
在同一行的Refresher@ViewChild("refresherRef") refresherRef: Refresher;
找不到名称“Refresher”。
解决方案
在 Angular 8 中, ViewChild 需要 2 个参数
尝试更换
@ViewChild("refresherRef")
和
@ViewChild("refresherRef", { static: false } )
推荐阅读
- javascript - onclick 在 chrome 上不起作用
- mysql - 查找所有没有关系的记录的速度非常慢
- java - 从模糊的 jar 和库 jar 依赖项创建 fatjar?
- typescript - 从 gulp 调用 webpack 时出现意外异常
- angularjs - 通过angularJS为聊天机器人附加html代码但不能使用相同的代码
- javascript - 查找并替换字符串中的所有匹配项
- git - Git 显示已删除的分支
- matplotlib - 如何在标题中打印方程式
- java - 如何使用spring mvc和jsp从mysql数据库中显示@Lob图像
- python - 解析日期时预期的字符串或类似字节的对象