【问题标题】:Ionic 4 Refresher is not passing in the refresher object so I can’t complete itIonic 4 Refresher 没有传入 refresher 对象,所以我无法完成它
【发布时间】:2020-06-21 03:41:33
【问题描述】:

在尝试完成复习时,我收到了错误

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);
    });
  }

我按照https://forum.ionicframework.com/t/ionic-4-refresher-is-not-passing-in-the-refresher-object-so-i-cant-complete-it/144213的指示进行操作

我试过了:

@ViewChild("refresherRef") refresherRef: Refresher;

load(refresher: Refresher) {
    this.refresherRef.complete();
}    

但它在@ViewChild("refresherRef") 处给了我一个错误

预期 2 个参数,但得到 1.ts(2554) core.d.ts(8436, 47): An 未提供“选择”的参数。

Refresher 在同一行 @ViewChild("refresherRef") refresherRef: Refresher;

找不到名称“Refresher”。

【问题讨论】:

    标签: angular ionic4 swiperefreshlayout pull-to-refresh


    【解决方案1】:

    在 Angular 8 中,ViewChild 有 2 个参数

    尝试替换

    @ViewChild("refresherRef")

    @ViewChild("refresherRef", { static: false } )

    【讨论】:

    • 谢谢!它解决了,但第二个错误保持不变。 Cannot find name 'Refresher'
    • 尝试以下行:@ViewChild('refresherRef', { static: false }) Refresher: ElementRef;
    • 从 '@angular/core' 导入 { ElementRef };
    • 我导入它,但现在它在load(refresher: Refresher) { this.refresherRef.complete(); } Cannot find name 'Refresher'.Property 'refresherRef' does not exist on type 'Tab1Page'. 两行都给我错误
    • 您还必须导入“Refresher”才能在当前组件中使用它。
    猜你喜欢
    • 1970-01-01
    • 2017-12-22
    • 1970-01-01
    • 2020-12-01
    • 1970-01-01
    • 2021-04-27
    • 2020-11-18
    • 2017-06-01
    • 2021-04-20
    相关资源
    最近更新 更多