1.alert
1,实现j简单提示框,2秒钟之后消失
import { AlertController } from '@ionic/angular';
constructor(public alertController: AlertController) { }
async presentAlert() {
const alert = await this.alertController.create({
header: '提示',
message: 'This is an alert message.'
});
await alert.present();
setTimeout(()=>{
this.alertController.dismiss()
},2000)
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/d21d254f313bc773f3d06a529d66f38b.png)
2.alert提示框
import { AlertController } from '@ionic/angular';
constructor(public alertController: AlertController) { }
async presentAlert() {
const alert = await this.alertController.create({
header: '提示',
message: '确定关闭此次会话吗?',
buttons: ['确定']
});
await alert.present();
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/38e7a7a7fae020beb2676313355130a2.png)
3.多按钮弹出框
async presentAlert() {
const alert = await this.alertController.create({
header: 'Alert',
subHeader: 'Subtitle',
message: 'This is an alert message.',
buttons: ['Cancel', 'Open Modal', 'Delete']
});
await alert.present();
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/201235ae7944166e13e77cd02fef4e08.png)
4.confirm提示框
async presentAlertConfirm() {
const alert = await this.alertController.create({
header: 'Confirm!',
message: 'Message <strong>text</strong>!!!',
buttons: [
{
text: 'Cancel',
role: 'cancel',
cssClass: 'secondary',
handler: (blah) => {
console.log('Confirm Cancel: blah');
}
}, {
text: 'Okay',
handler: () => {
console.log('Confirm Okay');
}
}
]
});
await alert.present();
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/4322b2b7f91daee3c0172534405df1ee.png)