我正在构建一个离子2应用程序,我正在使用以下组件
http://ionicframework.com/docs/components/#alert
import { AlertController } from 'ionic-angular';
export class MyPage {
constructor(public alertCtrl: AlertController) {
}
showAlert() {
let alert = this.alertCtrl.create({
title: 'New Friend!',
subTitle: 'Your friend, Obi wan Kenobi, just accepted your friend request!',
buttons: ['OK']
});
alert.present();
}
}
我怎样才能确保当我在框外点击警报时不会被解雇?
正如您在the AlertController docs中看到的,您可以在创建警报时使用enableBackdropDismiss
(boolean)选项:
是否应该通过点击背景来解除警报。默认为true
import { AlertController } from 'ionic-angular';
export class MyPage {
constructor(public alertCtrl: AlertController) {}
showAlert() {
let alert = this.alertCtrl.create({
title: 'New Friend!',
subTitle: 'Your friend, Obi wan Kenobi, just accepted your friend request!',
buttons: ['OK'],
enableBackdropDismiss: false // <- Here! :)
});
alert.present();
}
}
在离子4中,该选项已重命名为
backdropDismiss: false
在alertCtrl.create选项中设置enableBackdropDismiss:false