底部上拉框、弹窗

1.底部上拉框Action Sheets

  效果:

    

  代码可以直接去官网复制

import { ActionSheetController } from 'ionic-angular';
 constructor(public actionSheetCtrl: ActionSheetController) {

  }
  presentActionSheet() {
    const actionSheet = this.actionSheetCtrl.create({
      title: '选择',
      buttons: [
        {
          text: '本地照片',//显示文字
          role: 'destructive',//两个角色,不写默认destructive,如果是cancel则一直在弹出框的最下边
          icon: 'home',//显示图标
          handler: () => {
            console.log('本地照片');
          }
        },
        {
          text: '相机拍照',
          handler: () => {
            console.log('本地照片');
          }
        },
        {
          text: '取消',
          role: 'cancel',//cancel表示显示在最底部
          handler: () => {
            console.log('取消');
          }
        },
      ]
    });
    actionSheet.present();
  }

  html

  <button ion-button (click)="presentActionSheet()" block>上传照片</button>

2.弹窗

  

import { AlertController } from 'ionic-angular';
  constructor(public alertCtrl: AlertController) {

  }
  showAlert() {
    const alert = this.alertCtrl.create({
      title: '提示',
      subTitle: '操作成功',
      buttons: ['确认']
    });
    alert.present();
  }

  html

  <button ion-button (click)="showAlert()" block>弹框</button>

  官网上面还有很多种类型的弹窗,可以直接copy代码,展示一下官网的效果:

 3.加载弹窗Loading

  

import { LoadingController  } from 'ionic-angular';
  constructor(public loadingCtrl: LoadingController) {

  }
  presentLoading() {
    const loader = this.loadingCtrl.create({
      content: "加载中...",
      // duration: 3000 // 加载时间
    });

    // 若是没用使用duration,也可以使用以下语法设置加载时间
    setTimeout(() => {
      loader.dismiss();
    }, 3000);

    loader.present();
  }

  html

  <button ion-button (click)="presentLoading()" block>加载弹窗</button>

 

转载于:https://www.cnblogs.com/wskxy/p/9682013.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值