美文网首页
一个好看的消息提示插件 基于Vue

一个好看的消息提示插件 基于Vue

作者: zzzmh | 来源:发表于2019-02-15 12:48 被阅读0次

    最终效果图:


    在线演示: https://tczmh.gitee.io/alert-message-vue/

    申明

    代码并非纯原创,是基于这个jQuery例子,只是将其改写成了Vue,原代码出处是下面的链接
    jquery消息提示插件:类vue element message组件功能

    主要代码

    index.html

    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=Edge">
        <meta charset="UTF-8">
        <title>消息测试</title>
        <link rel="stylesheet" href="message.css">
    </head>
    <body>
    <div id="app">
        <h3>一个好看的消息提示插件 基于Vue</h3>
        <p>点击下方按钮进行测试</p>
        <button @click="Alert">默认</button>
        <button @click="Alert('操作成功 啦啦啦','success',2000)">成功</button>
        <button @click="Alert('请稍后 ...','info',2000)">提示</button>
        <button @click="Alert('网络异常?','warning',2000)">警告</button>
        <button @click="Alert('操作失败!','error',2000)">失败</button>
        <div class="c-message" :class="message.status" v-show="message.show">
            <div class="c-message--main">
                <i class="c-message--icon" :class="message.type"></i>
                <div class="c-message--tip">{{message.text}}</div>
            </div>
        </div>
        <p>
            并非纯原创,是基于这个jQuery例子,只是将其改写成了Vue
            <br>
            <a href="http://www.jq22.com/jquery-info16308" target="_blank">jquery消息提示插件:类vue element message组件功能</a>
        </p>
    </div>
    
    <script src="https://cdn.bootcss.com/vue/2.5.22/vue.min.js"></script>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                message: {
                    show: false,
                    type: 'c-message--success',
                    status: 'messageFadeInDown',
                    text: '操作成功',
                    time: 2000,
                    timeout: null
                }
            },
            methods: {
                Alert: function (text, type, time) {
                    vm.message.status = '';
                    clearTimeout(vm.timeout)
                    vm.message.text = (typeof text == 'string') && text ? text : '我是默认';
                    vm.message.time = time ? time : 2000;
                    vm.message.type = 'c-message--' + (type ? type : 'info');
                    vm.message.show = true;
                    vm.message.status = 'messageFadeInDown';
                    vm.timeout = setTimeout(function () {
                        vm.message.status = 'messageFadeOutUp'
                        // event.target.addEventListener('transitionend', function () {
                        //     alert('动画结束了!');
                        // }, false)
                    }, vm.message.time)
                }
            }
        });
    </script>
    </body>
    </html>
    

    message.css

    .c-message {
        position: fixed;
        top: 40px;
        left: calc(50% - 100px);;
        height: 40px;
        line-height: 40px;
        background: #fff;
        min-width: 200px;
        color: #666;
        box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
        text-align: center;
        z-index: 9999;
    }
    
    .c-message--main {
        padding-left: 50px;
        padding-right: 20px;
    }
    
    .c-message--icon {
        position: absolute;
        left: 0;
        top: 0;
        color: #fff;
        width: 40px;
        height: 40px;
    }
    
    .c-message--success {
        background: #13CE66 url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjQwcHgiIGhlaWdodD0iNDBweCIgdmlld0JveD0iMCAwIDQwIDQwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCAzOS4xICgzMTcyMCkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+CiAgICA8dGl0bGU+aWNvbl9zdWNjZXNzPC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGRlZnM+PC9kZWZzPgogICAgPGcgaWQ9IkVsZW1lbnQtZ3VpZGVsaW5lLXYwLjIuNCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9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jYsMjMuOTIzODU4MiAyNS45MzkwOTAyLDIzLjc3NjY1MTcgMjUuODE3MjYyNywyMy42NTQ4MjQzIEwyMi4xMzE5ODA0LDIwLjAwMDAwMTkgTDI1LjgxNzI2MjcsMTYuMzQ1MTc5NiBaIiBpZD0iUGF0aCIgZmlsbD0iI0ZGRkZGRiI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+) no-repeat 0 50%;
    }
    
    .c-message--info {
        background: #20A0FF url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjQwcHgiIGhlaWdodD0iNDBweCIgdmlld0JveD0iMCAwIDQwIDQwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCAzOS4xICgzMTcyMCkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+CiAgICA8dGl0bGU+aWNvbl9pbmZvPC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGRlZnM+PC9kZWZzPgogICAgPGcgaWQ9IkVsZW1lbnQtZ3VpZGVsaW5lLXYwLjIuNCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9Ik1lc3NhZ2UiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC02MC4wMDAwMDAsIC0xNTIuM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NDc5MzUgQzIxLjgwNTU1NzMsMTIuOTI0NjU3NSAyMiwxMy4zNzM3NzI2IDIyLDEzLjkwMjE0OTEgQzIyLDE0LjQzMDUyNTUgMjEuODA1NTU3MywxNC44Nzk2NDA2IDIxLjQxNjY2NjcsMTUuMjQ5NTA0NiBDMjEuMDI3Nzc2LDE1LjYxOTM2ODcgMjAuNTU1NTU3MywxNS44MDQyOTgxIDIwLDE1LjgwNDI5ODEgWiIgaWQ9IkNvbWJpbmVkLVNoYXBlIiBmaWxsPSIjRkZGRkZGIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyMC4wMDAwMDAsIDIwLjAwMDAwMCkgc2NhbGUoMSwgLTEpIHRyYW5zbGF0ZSgtMjAuMDAwMDAwLCAtMjAuMDAwMDAwKSAiPjwvcGF0aD4KICAgICAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==) no-repeat 0 50%;
    }
    
    @keyframes messageFadeInDown {
        0% {
            -webkit-transform: translate3d(0, -100%, 0);
            transform: translate3d(0, -100%, 0)
        }
        100% {
            -webkit-transform: none;
            transform: none
        }
    }
    
    .c-message.messageFadeInDown {
        -webkit-animation-duration: .6s;
        animation-duration: .6s;
        -webkit-animation-fill-mode: both;
        animation-fill-mode: both;
        -webkit-animation-name: messageFadeInDown;
        animation-name: messageFadeInDown;
    }
    
    @keyframes messageFadeOutUp {
        0% {
            opacity: 1
        }
        100% {
            opacity: 0;
            -webkit-transform: translateY(-100%);
            transform: translateY(-100%)
        }
    }
    
    .c-message.messageFadeOutUp {
        -webkit-animation-duration: .6s;
        animation-duration: .6s;
        -webkit-animation-fill-mode: both;
        animation-fill-mode: both;
        -webkit-animation-name: messageFadeOutUp;
        animation-name: messageFadeOutUp
    }
    

    END

    再次申明,并非原创代码,而是从jq22下载原作者的代码以后,发现我自己项目没有jQuery依赖,于是改写成了vue依赖。其实我的前端水平也是一般般的,改的不好的地方还请见谅!

    源码gitee: https://gitee.com/tczmh/alert-message-vue
    在线演示: https://tczmh.gitee.io/alert-message-vue/
    原作者jq22地址:http://www.jq22.com/jquery-info16308

    相关文章

      网友评论

          本文标题:一个好看的消息提示插件 基于Vue

          本文链接:https://www.haomeiwen.com/subject/thppeqtx.html