【发布时间】:2017-08-25 08:39:40
【问题描述】:
是否可以为每种 toast 类型单独设置 toastr 选项?
我的烤面包机代码
toastr.options = {
"closeButton": true,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-bottom-right",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "60000",
"extendedTimeOut": "60000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
const infoMessage = $(".js-toast-message-info").html();
if (infoMessage && infoMessage.length > 0) {
toastr.info(infoMessage);
}
const errorMessage = $(".js-toast-message-error").html();
if (errorMessage && errorMessage.length > 0) {
toastr.error(errorMessage);
}
const warningMessage = $(".js-toast-message-warning").html();
if (warningMessage && warningMessage.length > 0) {
toastr.warning(warningMessage);
}
const successMessage = $(".js-toast-message-success").html();
if (successMessage && successMessage.length > 0) {
toastr.success(successMessage);
}
我已经尝试将我想要的不同选项类型放在特定 toastr 类型的 if 语句中,但没有结果。
有没有简单的方法来实现这一点?
【问题讨论】: