开始使用 API对象 布局容器和栅格系统 Color 色彩 Button 按钮 Tag 标签 Badge 数字角标 List 列表 Grid 宫格 Card 卡片 Noticebar 通告 Steps 步骤条 Icon 图标 Srarch 搜索 侧滑菜单 图片上传 图片预览 图片裁剪 图片主色 星级评价 选择器 下拉选择 选项卡 生成二维码 复制剪贴板 物流信息 加入购物车 波浪特效 水球图 倒计时 雪花飘落 loading动画 toast消息提示弹窗 dialog提示窗 actionsheet操作表 actionmenu分享弹窗 popover菜单 picker多级联动 poster广告弹窗 keypad数字键盘 chatbox js聊天输入框

dialog提示窗

需要先引入相关的CSS和JS文件:

<link rel="stylesheet" type="text/css" href="static/css/aui.min.css"/>

<script src="static/js/aui.min.js" type="text/javascript" charset="utf-8"></script>

参数介绍

参数 类型 描述 默认值 必选
warp string 父容器元素 ‘body’
title string 标题 ‘’
msg string 提示内容 ‘’
btns arr 按钮,默认按钮为“确定” 分别可设置btns值为
1:[‘按钮1’, ‘按钮2’]
2:[{name: ‘按钮1’, color: ‘’},{name: ‘按钮2’, color: ‘’}]
[“确定”]
mask boolean 是否显示遮罩蒙版 true
touchClose boolean 触摸遮罩是否关闭模态弹窗 true
theme number 主题样式,控制模态弹窗按钮显示风格(
1: 大按钮;
2: 小按钮-居右分布;
3: 按钮宽度等于父级宽度100%,适用于按钮文字过多情况)
‘col’
items arr prompt–input框列表配置[{label: ‘姓名:’, type: ‘text’, value: ‘(可选)’, placeholder: ‘请输入姓名’}] []
duration number 显示时间 2000
style object {
w: ‘’, //–可选参数,模态窗宽度,默认80%
h: ‘’, //–可选参数,模态窗高度,默认"auto"自适应
bg: ‘’,//–可选参数,模态窗背景色,默认白色
zIndex: ‘’, //–可选参数,模态窗层级
title: {
bg: “”,
color: “”,
lineHeight: “”,
textAlign: “”,
fontSize: “”,
padding: “”}}
‘’

示例代码

<div class="container">
    <header class="aui-header">
        <a class="aui-header-left" onclick="aui.closeWin()"><i class="iconfont iconreturn"></i></a>
        <div class="aui-header-title">dialog模态弹窗</div>
    </header>
    <div class="aui-content">
        <lable class="aui-list-title">1、大按钮风格</lable>
        <button class="aui-btn aui-btn-blue dialog-0">alert单按钮提醒弹窗</button>
        <button class="aui-btn aui-btn-blue dialog-1">confirm双按钮提醒弹窗</button>
        <button class="aui-btn aui-btn-blue dialog-2">delete删除提醒弹窗</button>
        <button class="aui-btn aui-btn-blue dialog-3">prompt输入弹窗</button>
        <button class="aui-btn aui-btn-blue dialog-4">自定义带图标提示弹窗</button>
        <lable class="aui-list-title">2、小按钮风格</lable>
        <button class="aui-btn aui-btn-blue dialog-5">alert单按钮提醒弹窗</button>
        <button class="aui-btn aui-btn-blue dialog-6">confirm双按钮提醒弹窗</button>
        <button class="aui-btn aui-btn-blue dialog-7">delete删除提醒弹窗</button>
        <button class="aui-btn aui-btn-blue dialog-8">prompt输入弹窗</button>
        <lable class="aui-list-title">3、两个以上按钮</lable>
        <button class="aui-btn aui-btn-blue dialog-9">多按钮弹窗</button>
        <lable class="aui-list-title">3、带背景色按钮</lable>
        <button class="aui-btn aui-btn-blue dialog-10">alert单按钮提醒弹窗</button>
        <button class="aui-btn aui-btn-blue dialog-11">confirm双按钮提醒弹窗</button>
        <button class="aui-btn aui-btn-blue dialog-12">delete删除提醒弹窗</button>
    </div>
</div>
<script type="text/javascript">
    window.addEventListener("load", function(){
        //A、大按钮风格弹窗
        //alert单按钮提醒弹窗
        document.querySelector(".dialog-0").addEventListener("click", function(){
            aui.alert({
                title: "提示", //可选
                msg: "您点击了alert单按钮模态弹窗!",
                mask: true,
                touchClose: true, //可选
                btns: ["确定"], //可选
                //或btns: [{name: '按钮1', color: '#f00'},{name: '按钮2', color: '#00f'}], //可选
                theme: 1, //可选
                style: { //可选
                    w: "80vw",
                    h: "auto",
                    bg: '#FFF',
                    zIndex: 999,
                    animate: "aui-scale-in-tosmall-dialog",
                    title: {
                        bg: "#FFF",
                        color: "#333",
                        lineHeight:"55px",
                        fontSize: "17px",
                        textAlign: "center",
                        padding: "0px"
                    }
                }
            },function(ret){
                console.log(ret.index);
                if(ret.index == 0){
                    aui.toast({msg: "您点击了确定"});
                }
            });
        });
        //confirm双按钮提醒弹窗
        document.querySelector(".dialog-1").addEventListener("click", function(){
            aui.confirm({
                title: "提示", //可选
                msg: "您点击了confirm双按钮模态弹窗!",
                btns: ["取消", "确定"],
            },function(ret){
                console.log(ret.index);
                if(ret.index == 1){
                    aui.toast({msg: "您点击了确定"});
                }
            });
        });
        //delete删除提醒弹窗
        document.querySelector(".dialog-2").addEventListener("click", function(){
            aui.delete({
                title: "提示", //可选
                msg: "您点击了delete删除模态弹窗!",
                btns: ["取消", "删除"],
            },function(ret){
                console.log(ret.index);
                if(ret.index == 1){
                    aui.toast({msg: "您点击了删除"});
                }
            });
        });
        //prompt输入弹窗
        document.querySelector(".dialog-3").addEventListener("click", function(){
            aui.prompt({
                title: "提示", //可选
                items: [{
                    label: '姓名:',
                    type: 'text',
                    value: '',
                    placeholder: '请输入姓名'
                },{
                    label: '年龄:',
                    type: 'number',
                    value: '',
                    placeholder: '请输入年龄'
                }],
                btns: ["取消", "确定"],
            },function(ret){
                console.log(ret.data);
                if(ret.index == 1)
                {
                    aui.alert({
                        title: "输入结果",
                        msg: "<div style='text-align: left;'>姓名:" + ret.data[0] + "</br>年龄:" + ret.data[1]+"</div>",
                        btns: ["确定"],
                    }, function(ret){
                        if(ret.index == 0){
                            aui.toast({msg: "您点击了确定"});
                        }
                    });
                }
            });
        });
        //confirm带图标双按钮提醒弹窗
        document.querySelector(".dialog-4").addEventListener("click", function(){
            aui.confirm({
                title: "提示", //可选
                msg: "<div style='text-align: center;'>"
                    +"<img src='../../../static/img/success-green.png' style='width: 60px; margin: 0 auto;'>"
                    +"<p style='width: 100%; line-height: 25px; color: 15px;'>带图标模态弹窗</p>"
                +"</div>",
                btns: ["取消", "确定"],
            },function(ret){
                console.log(ret.index);
                if(ret.index == 1){
                    aui.toast({msg: "您点击了确定"});
                }
            });
        });
        //B、小按钮风格弹窗
        //alert单按钮提醒弹窗
        document.querySelector(".dialog-5").addEventListener("click", function(){
            aui.alert({
                title: "提示", //可选
                msg: "您点击了alert单按钮模态弹窗!",
                btns: ["确定"], //可选
                theme: 2, //可选
            },function(ret){
                console.log(ret.index);
                if(ret.index == 1){
                    aui.toast({msg: "您点击了确定"});
                }
            });
        });
        //confirm双按钮提醒弹窗
        document.querySelector(".dialog-6").addEventListener("click", function(){
            aui.confirm({
                title: "提示", //可选
                msg: "您点击了confirm双按钮模态弹窗!",
                btns: ["取消", "确定"],
                theme: 2, //可选
            },function(ret){
                console.log(ret.index);
                if(ret.index == 1){
                    aui.toast({msg: "您点击了确定"});
                }
            });
        });
        //delete删除提醒弹窗
        document.querySelector(".dialog-7").addEventListener("click", function(){
            aui.delete({
                title: "提示", //可选
                msg: "您点击了delete删除模态弹窗!",
                btns: ["取消", "删除"],
                theme: 2, //可选
            },function(ret){
                console.log(ret.index);
                if(ret.index == 1){
                    aui.toast({msg: "您点击了删除"});
                }
            });
        });
        //prompt输入弹窗
        document.querySelector(".dialog-8").addEventListener("click", function(){
            aui.prompt({
                title: "提示", //可选
                items: [{
                    label: '姓名:',
                    type: 'text',
                    value: '',
                    placeholder: '请输入姓名'
                },{
                    label: '年龄:',
                    type: 'number',
                    value: '',
                    placeholder: '请输入年龄'
                }],
                btns: ["取消", "确定"],
                theme: 2, //可选
            },function(ret){
                console.log(ret.data);
                if(ret.index == 1)
                {
                    aui.alert({
                        title: "输入结果",
                        msg: "<div style='text-align: left;'>姓名:" + ret.data[0] + "</br>年龄:" + ret.data[1]+"</div>",
                        btns: ["确定"],
                        theme: 2, //可选
                    }, function(ret){
                        if(ret.index == 0){
                            aui.toast({msg: "您点击了确定"});
                        }
                    });
                }
            });
        });
        //C、多按钮弹窗
        document.querySelector(".dialog-9").addEventListener("click", function(){
            aui.confirm({
                title: "提示", //可选
                msg: "您点击了多按钮弹窗!",
                btns: [{name: '残忍拒绝', color: ''},{name: '再逛逛', color: ''}, {name: "返回首页", color: "#909090"}], //可选
                theme: 3, //可选
            },function(ret){
                console.log(ret.index);
                if(ret.index == 0){
                    aui.toast({msg: "您点击了残忍拒绝"});
                }
                else if(ret.index == 1){
                    aui.toast({msg: "您点击了再逛逛"});
                }
                else if(ret.index == 2){
                    aui.toast({msg: "您点击了返回首页"});
                }
            });
        });

        //D、带背景色按钮
        //alert单按钮提醒弹窗
        document.querySelector(".dialog-10").addEventListener("click", function(){
            aui.alert({
                title: "提示", //可选
                msg: "您点击了多按钮弹窗!",
                btns: ["确定"], //可选
                theme: 4, //可选
            },function(ret){
                console.log(ret.index);
                if(ret.index == 0){
                    aui.toast({msg: "您点击了确定"});
                }
            });
        });
        //confirm双按钮提醒弹窗
        document.querySelector(".dialog-11").addEventListener("click", function(){
            aui.confirm({
                title: "提示", //可选
                msg: "您点击了多按钮弹窗!",
                btns: ["取消", "确定"], //可选
                theme: 4, //可选
            },function(ret){
                console.log(ret.index);
                if(ret.index == 0){
                    aui.toast({msg: "您点击了取消"});
                }
                else if(ret.index == 1){
                    aui.toast({msg: "您点击了确定"});
                }
            });
        });
        //delete删除提醒弹窗
        document.querySelector(".dialog-12").addEventListener("click", function(){
            aui.delete({
                title: "提示", //可选
                msg: "您点击了delete删除模态弹窗!",
                btns: ["取消", "删除"],
                theme: 4, //可选
            },function(ret){
                console.log(ret.index);
                if(ret.index == 1){
                    aui.toast({msg: "您点击了删除"});
                }
            });
        });
    });
</script>