2017-04-05 58 views
0

當我在頁面上顯示一個提醒時,用戶可以點擊背景並提醒解散。有沒有辦法讓背景不可點擊?離子2彈出的背景仍然可點擊

this.alert = this.alertController.create({ 
           title: 'Error', 
           subTitle: "You lost connection !", 
           buttons: [ { 
           text: 'Refresh', 
           handler:() => { 
            if(!data){ 
            this.alert.dismiss().then(() => { 
             this.alert = null; 
           }); 
            } 
         } 
        }] 
       }); 

回答

1

只需在創建警報時將enableBackdropDismiss選項設置爲false即可。例如:

this.alert = this.alertController.create({ 
           title: 'Error', 
           subTitle: "You lost connection !", 
           enableBackdropDismiss: false, 
           buttons: [ { 
           text: 'Refresh', 
           handler:() => { 
            if(!data){ 
            this.alert.dismiss().then(() => { 
             this.alert = null; 
           }); 
            } 
         } 
        }] 
       }); 

希望這對你有所幫助。謝謝。