首页 > 解决方案 > 在 Ionic3 中下拉刷新时出错

问题描述

嘿,我正在尝试通过下拉 ionic 来刷新我的产品列表。第一次工作,但之后它给出了这个错误

Error: Uncaught (in promise): removeView was not found
    at c (http://localhost:8101/build/polyfills.js:3:19752)
    at c (http://localhost:8101/build/polyfills.js:3:19461)
    at http://localhost:8101/build/polyfills.js:3:20233
    at t.invokeTask (http://localhost:8101/build/polyfills.js:3:15660)
    at Object.onInvokeTask (http://localhost:8101/build/vendor.js:5125:33)
    at t.invokeTask (http://localhost:8101/build/polyfills.js:3:15581)
    at r.runTask (http://localhost:8101/build/polyfills.js:3:10834)
    at o (http://localhost:8101/build/polyfills.js:3:7894)

我的刷新内容的代码是 For HTML

<ion-refresher (ionRefresh)="doRefresh($event)">
        <ion-refresher-content  pullingIcon="arrow-dropdown"
        pullingText="Pull to refresh"
        refreshingSpinner="circles"
        refreshingText="Refreshing..."></ion-refresher-content>
    </ion-refresher>

在 TS 文件中

doRefresh(refresher) {
    console.log('Begin async operation', refresher);

    let loading = this.loadingCtrl.create({
      spinner: 'hide',
      content: `<img src="./assets/imgs/gif.svg" class="h15" />`,
    });
    this.service.getBrand().then((response:any)=>{
      loading.dismiss();
      this.brandlist = response;
    });
    this.serv.getProductList(this.sub_categoryes,this.filterCopy,this.newarrival,this.brand).then((response:any)=>{
      loading.dismiss();
      console.log(response);

      this.productlist = response;
      this.tmp_arr=response;
    });
    loading.present();
  }

标签: angulartypescriptionic-frameworkionic3typescript2.0

解决方案


手动调用时dismiss,需要等到loading.present()解决

 this.loading.present().then(() => {
    this.service.getBrand().then((response: any) => {
        loading.dismiss();
        this.brandlist = response;
    });

    this.serv.getProductList(this.sub_categoryes, this.filterCopy, this.newarrival, this.brand).then((response: any) => {
        loading.dismiss();
        console.log(response);

        this.productlist = response;
        this.tmp_arr = response;
    });

});

检查这个


推荐阅读