简体   繁体   English

如何在离子2中进行自定义警报?

[英]How to make customized alert in ionic 2?

Can you please tell me how to make a customized alert in ionic 2 ? 你能告诉我如何在离子2中做出自定义警报吗? like add image at top right corner make it clickable 喜欢在右上角添加图片使其可点击

We Can Use Modal Instead Of using Alert by Giving Padding to Modal.. Add Modal & Write This Code In App.scss :) 我们可以使用模态而不是通过填充到模态使用警报..添加模式并在App.scss中编写此代码:)

ion-modal {
    background-color: rgba(0, 0, 0, 0.5);
    ion-content.content{
        top: 20%;
        left: 10%;

        width: 80%;
        height: 50%;
        border-radius: 10px;
        .scroll-content {
            border-radius: 20px;
        }
    }
}

For these I always just create a custom modal page. 对于这些我总是只创建一个自定义模态页面。 You can full control all aspects of a modal, including sizing. 您可以完全控制模态的所有方面,包括大小调整。 It's basically just a page with a controller and template, super easy to implement too. 它基本上只是一个带有控制器和模板的页面,也非常容易实现。

http://ionicframework.com/docs/v2/api/components/modal/ModalController/ should get you all set http://ionicframework.com/docs/v2/api/components/modal/ModalController/应该可以帮到你了

I am using following to get the desired modal size. 我正在使用以下来获得所需的模态大小。

.always-modal .modal-wrapper{
    background: rgba(0, 0, 0, 0.7);
    width: 100%;
    height: 100%;
    left: unset !important;
    top: unset !important;
    .ion-page{
        margin:0 auto;
        position: relative;
        top:10%;
        width: 75%;
        height: 80%;
    }
}

Now whenever I need a modal with these properties I pass following in modal options. 现在每当我需要一个具有这些属性的模态时,我会在模态选项中传递以下内容。

{ cssClass: "always-modal" }

I am not able to figure out how to dismiss this modal when user taps on background area. 当用户点击背景区域时,我无法弄清楚如何解雇此模态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM