cute-alert.min.js是一款纯js的自适应弹出层弹出框提示插件

cute-alert.min.js是一款纯js的自适应弹出层弹出框提示插件

cute-alert.min.js是一款纯js的自适应弹出层弹出框提示插件,可实现弹出成功提示框、错误提示框、警告提示框、确认框等样式的弹出框,还能兼容手机端。

使用方式:

第一步引入插件的css和script脚本

<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/cute-alert.css">
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/cute-alert.min.js"></script>

第二步增加触发按钮

<button class="btn btn-success" id="success">Success</button>
        <button class="btn btn-error" id="error">error</button>
        <button class="btn btn-warning" id="warning">Warning</button>
        <button class="btn btn-info" id="info">Info</button>
        <button class="btn btn-danger" id="confirm">Confirm</button>
        <button class="btn btn-primary" id="toast">Toast</button>

第三步配置参数

cuteAlert({
        type: 'success',//支持success  error info question warining等样式
       title: 'Success Title',//标题
        message: 'Success Message',//内容
       buttonText: 'Okay'//按钮
            })

完整代码:

<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">


    <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/cute-alert.css">
</head>

<body>
    <div class="container mt-5">
        <h1>弹出警告框Js插件</h1>

        <button class="btn btn-success" id="success">Success</button>
        <button class="btn btn-error" id="error">error</button>
        <button class="btn btn-warning" id="warning">Warning</button>
        <button class="btn btn-info" id="info">Info</button>
        <button class="btn btn-danger" id="confirm">Confirm</button>
        <button class="btn btn-primary" id="toast">Toast</button>
    </div>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/cute-alert.min.js"></script>
    <script>
        var success = document.getElementById('success');
        success.addEventListener('click', ()=>{
            cuteAlert({
                type: 'success',
                title: 'Success Title',
                message: 'Success Message',
                buttonText: 'Okay'
            })
        })

        var error = document.getElementById('error');
        error.addEventListener('click', ()=>{
            cuteAlert({
                type: 'error',
                title: 'Error Title',
                message: 'Error Message',
                buttonText: 'Okay'
            })
        })

        var warning = document.getElementById('warning');
        warning.addEventListener('click', ()=>{
            cuteAlert({
                type: 'warning',
                title: 'Warning Title',
                message: 'Warning Message',
                buttonText: 'Okay'
            })
        })

        var info = document.getElementById('info');
        info.addEventListener('click', ()=>{
            cuteAlert({
                type: 'info',
                title: 'Info Title',
                message: 'Info Message',
                buttonText: 'Okay'
            })
        })

        var confirm = document.getElementById('confirm');
        confirm.addEventListener('click', ()=>{
            cuteAlert({
                type: 'question',
                title: 'Confirm Title',
                message: 'Confirm Message',
                confirmText: 'Okay',
                cancelText: 'Cancel'
            }).then((e)=>{
                if ( e == ('Thanks')){
            } else {
    alert(':-(');
        }
        })
        })

        var toast = document.getElementById('toast');
        toast.addEventListener('click', ()=>{
            cuteToast({
                type: 'success',
                message: 'Info Message',
                timer: 5000
            })
        })
    </script>


</body>



</html>



立即下载cute-alert.min.js查看所有js插件

网友评论0

程序员在线工具箱