23 lines
560 B
JavaScript
23 lines
560 B
JavaScript
// 工具函数模块
|
|
const UtilsModule = (function() {
|
|
// Toast初始化
|
|
const toastEl = document.getElementById('toast');
|
|
const toast = new bootstrap.Toast(toastEl, {
|
|
autohide: true,
|
|
delay: 3000
|
|
});
|
|
|
|
// 显示Toast提示
|
|
function showToast(message) {
|
|
$('.toast-body').text(message);
|
|
toast.show();
|
|
}
|
|
|
|
// 暴露公共方法
|
|
return {
|
|
showToast: showToast
|
|
};
|
|
})();
|
|
|
|
// 将需要在其他模块中直接使用的函数暴露到全局
|
|
window.showToast = UtilsModule.showToast; |