사용 단계:
-
toastr.css 및 toastr.js 파일 로드
-
글로벌 구성. 편의를 위해 toastr.js를 다음 설정에 대한 글로벌 설정으로 작성하는데, 보통 utils(global tools) 폴더에 있으며, 사용할 때 이 설정 파일을 불러오기만 하면 됩니다.
toastr.options = { // "closeButton": false, // "debug": false, // "newestOnTop": false, // "progressBar": false, "positionClass": "toast-center-center", // 提示框位置,这里填类名 // "preventDuplicates": false, // "onclick": null, "showDuration": "300", // 提示框渐显所用时间 "hideDuration": "300", // 提示框隐藏渐隐时间 "timeOut": "2000", // 提示框持续时间 // "extendedTimeOut": "1000", // "showEasing": "swing", // "hideEasing": "linear", // "showMethod": "fadeIn", // "hideMethod": "fadeOut" }
-
호출 방법, 직접 사용
toastr.info('提示信息'); // 普通提示 toastr.success('提示信息'); // 成功提示 toastr.warning('提示信息'); // 警告提示 toastr.error('提示信息'); // 错误提示