Jquery toastr提示框


toastr是一個基於JQuery的消息提示插件;


1. 下載toastr和jquery

https://jquery.com/download/

https://codeseven.github.io/toastr/

2. 引入jquery和toastr

<script src="./resources/jquery-3.3.1.min.js"></script>
<script src="../resources/js/toastr/toastr.min.js"></script>
<link rel="stylesheet" href="../resources/css/toastr/toastr.min.css" />

3. 配置提示框,通過自定義配置,達到不同的效果


toastr.options = {  

        closeButton: false,  
        debug: false,  
        progressBar: true,  
        positionClass: "toast-bottom-center",  
        onclick: null,  
        showDuration: "300",  
        hideDuration: "1000",  
        timeOut: "2000",  
        extendedTimeOut: "1000",  
        showEasing: "swing",  
        hideEasing: "linear",  
        showMethod: "fadeIn",  
        hideMethod: "fadeOut"  

    };

參數說明

closeButton:false,是否顯示關閉按鈕(提示框右上角關閉按鈕);
debug:false,是否為調試;
progressBar:false,是否顯示進度條(設置關閉的超時時間進度條);
positionClass,消息框在頁面顯示的位置


  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

onclick,點擊消息框自定義事件
showDuration: “300”,顯示動作時間
hideDuration: “1000”,隱藏動作時間
timeOut: “2000”,自動關閉超時時間
extendedTimeOut: “1000”
showEasing: “swing”,
hideEasing: “linear”,
showMethod: “fadeIn” 顯示的方式,和jquery相同
hideMethod: “fadeOut” 隱藏的方式,和jquery相同

4. 根據不同提示使用不同的提示框;

格式: toastr.消息類型方法('消息標題;可省略', '消息內容') /// toastr['消息類型方法']('消息標題;可省略', '消息內容')

//常規消息提示,默認背景為淺藍色  
 toastr.info("你有新消息了!");  
//成功消息提示,默認背景為淺綠色 
 toastr.success("你有新消息了!"); 
//警告消息提示,默認背景為橘黃色 
 toastr.warning("你有新消息了!"); 
//錯誤消息提示,默認背景為淺紅色 
 toastr.error("你有新消息了!");  
//帶標題的消息框
 toastr.success("你有新消息了!","消息提示");
//另一種調用方法
 toastr["info"]("你有新消息了!","消息提示");


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM