【问题标题】:ionic 3 loadingcontroller enable backdrop dismiss not workingionic 3 loadingcontroller 启用背景关闭不工作
【发布时间】:2017-12-18 05:29:13
【问题描述】:

我已经使用以下代码成功创建了一个加载器

presentLoading() {
    this.loadingCtrl.create({
      content: 'Please wait...',
      //duration: 3000,
      dismissOnPageChange: true,
      showBackdrop: true,
    }).present();
  }

但我无法将enableBackdropDismiss 放置在代码中的任何位置,我不知道该放在哪里以及如何使用它来关闭我的加载器

【问题讨论】:

    标签: angular ionic3


    【解决方案1】:

    您可以像使用其他属性一样使用它。当它设置为true 时,用户可以通过点击背景来关闭您的加载。如果您想解除代码中的加载,您需要创建一个变量来表示它:

    presentLoading() {
        let loading = this.loadingCtrl.create({
          content: 'Please wait...',
          //duration: 3000,
          dismissOnPageChange: true,
          showBackdrop: true,
          enableBackdropDismiss: true
        }).present();
        //Compute, ajax call or what ever you want
        //Dismiss loading
        loading.dismiss();
      }
    

    【讨论】:

    • 我尝试过这样做,它会给出以下错误:Argument of type '{ content: string;解除页面更改:真;显示背景:真; enableBackdropDismiss:布尔值; }' 不可分配给“LoadingOptions”类型的参数。对象字面量只能指定已知属性,而“LoadingOptions”类型中不存在“enableBackdropDismiss”。
    • 注意:必须使用,而不是;来分隔属性
    • 我只使用你的代码,仍然出现同样的错误
    • 为什么你会得到这个{ content: string; dismissOnPageChange: true; showBackdrop: true; enableBackdropDismiss: boolean; } 它有;。我的代码只使用,
    猜你喜欢
    • 2017-08-23
    • 2019-05-07
    • 1970-01-01
    • 2016-04-27
    • 2020-07-08
    • 1970-01-01
    • 2022-11-19
    • 2017-10-19
    • 2014-04-14
    相关资源
    最近更新 更多