首页 > 其他 > 详细

toastr简单使用

时间:2020-06-07 12:10:48      阅读:48      评论:0      收藏:0      [点我收藏+]

代码

<!--jquery-->
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<!--toastr-->
<link href="https://cdn.bootcdn.net/ajax/libs/toastr.js/2.1.4/toastr.min.css" rel="stylesheet">
<script src="https://cdn.bootcdn.net/ajax/libs/toastr.js/2.1.4/toastr.min.js"></script>

<button id="test-btn">测试</button>
<script>
    $(‘#test-btn‘).click(function () {
        toastr.info(‘info‘);
        toastr.success(‘success‘);
        toastr.warning(‘warning‘);
        toastr.error(‘error‘);
        toastr.info(‘info‘,‘消息标题‘);
        toastr.success(‘success‘,‘消息标题‘);
        toastr.warning(‘warning‘,‘消息标题‘);
        toastr.error(‘error‘,‘消息标题‘);
    })
    // toastr自定义
    toastr.options = {
        closeButton: false, // 是否显示关闭按钮,(提示框右上角关闭按钮)
        debug: false, // 是否使用deBug模式
        progressBar: true, // 是否显示进度条,(设置关闭的超时时间进度条)
        positionClass: "toast-top-right", // 设置提示款显示的位置
        onclick: null, // 点击消息框自定义事件?
        showDuration: "300", // 显示动画的时间
        hideDuration: "1000", //  消失的动画时间
        timeOut: "2000", //  自动关闭超时时间?
        extendedTimeOut: "1000", //  加长展示时间
        showEasing: "swing", //  显示时的动画缓冲方式
        hideEasing: "linear", //   消失时的动画缓冲方式
        showMethod: "fadeIn", //   显示时的动画方式
        hideMethod: "fadeOut" //   消失时的动画方式
    };
    /*
        toast-top-left  顶端左边
        toast-top-right    顶端右边
        toast-top-center  顶端中间
        toast-top-full-width 顶端,宽度铺满整个屏幕
        toast-botton-right  
        toast-bottom-left
        toast-bottom-center
        toast-bottom-full-width
    */
</script>

效果图

技术分享图片

toastr简单使用

原文:https://www.cnblogs.com/wstong/p/13059718.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!