英文:
how can I resolve this warning: SweetAlert2: Unknown parameter "onOpen"?
问题
以下是代码部分的翻译:
my sweet alert show this warning, how can I resolve this? any idea
我的Sweet Alert显示这个警告,如何解决?有什么想法
don't know what causes this warning when I fire this Sweet Alert, it shows this warning.
不知道在我触发Sweet Alert时是什么导致了这个警告,它显示这个警告。
here is the alert component code:
这是警报组件的代码:
import Swal from "sweetalert2";
import Swal from "sweetalert2";
const ToastComponent = Swal.mixin({
const ToastComponent = Swal.mixin({
toast: true,
position: "top-end",
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
onOpen: (toast) => {
toast.addEventListener("mouseenter", Swal.stopTimer);
toast.addEventListener("mouseleave", Swal.resumeTimer);
},
});
toast: true,
position: "top-end",
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
onOpen: (toast) => {
toast.addEventListener("mouseenter", Swal.stopTimer);
toast.addEventListener("mouseleave", Swal.resumeTimer);
},
});
export const Alert = (type = "", title = "", description = "") =>
Swal.fire(title, description, type);
export const Alert = (type = "", title = "", description = "") =>
Swal.fire(title, description, type);
export const Toast = (type = "", title = "") =>
ToastComponent.fire({
icon: type,
title,
});
export const Toast = (type = "", title = "") =>
ToastComponent.fire({
icon: type,
title,
});
请注意,上述翻译中,我将HTML实体编码"
转换为双引号"
以更好地呈现代码。如果您需要进一步的帮助,请随时提问。
英文:
my sweet alert show this warning, how can I resolve this? any idea
don't know what causes this warning when I fire this Sweet Alert, it shows this warning.
here is the alert component code:
import Swal from "sweetalert2";
const ToastComponent = Swal.mixin({
toast: true,
position: "top-end",
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
onOpen: (toast) => {
toast.addEventListener("mouseenter", Swal.stopTimer);
toast.addEventListener("mouseleave", Swal.resumeTimer);
},
});
export const Alert = (type = "", title = "", description = "") =>
Swal.fire(title, description, type);
export const Toast = (type = "", title = "") =>
ToastComponent.fire({
icon: type,
title,
});
答案1
得分: 1
From
onOpen: (toast) => {
toast.addEventListener("mouseenter", Swal.stopTimer);
toast.addEventListener("mouseleave", Swal.resumeTimer);
}
To
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer);
toast.addEventListener('mouseleave', Swal.resumeTimer);
}
英文:
In case of onOpen didn't work, I think you can use didOpen.
From
onOpen: (toast) => {
toast.addEventListener("mouseenter", Swal.stopTimer);
toast.addEventListener("mouseleave", Swal.resumeTimer);
}
To
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
I made a playground here.
Codepen.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论