javascript - 甜蜜警报2 : correct way to completely disable animation with version >= 9. 0.0

标签 javascript sweetalert2

在版本 9.0.0 之前,我使用此代码完全禁用 toast 警报上的动画。

Swal.fire({
    animation : false,
    toast: true,
    ....
});

现在版本 9.* 我尝试使用此代码,结果看起来相同

Swal.fire({
    showClass : { popup : "swal2-noanimation", backdrop : "swal2-noanimation", icon : "swal2-noanimation"},
    //hideClass : { popup : "swal2-noanimation", backdrop : "swal2-noanimation", icon : "swal2-noanimation"},
    toast: true,
    ....
});

如果我还启用属性hideClass,我无法使用方法Swal.close()隐藏警报。

那么正确的解决方案是什么才能获得与之前相同的效果?

最佳答案

根据拒绝消息:

SweetAlert2: "animation" is deprecated and will be removed in the next major release. Please use "showClass" and "hideClass" instead.

Swal.fire({
  icon: 'success',
  title: 'I am not animated',
  showClass: {
    backdrop: 'swal2-noanimation', // disable backdrop animation
    popup: '',                     // disable popup animation
    icon: ''                       // disable icon animation
  },
  hideClass: {
    popup: '',                     // disable popup fade-out animation
  },
})
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

阅读发行说明以查看所有重大更改:https://github.com/sweetalert2/sweetalert2/releases/tag/v9.0.0

关于javascript - 甜蜜警报2 : correct way to completely disable animation with version >= 9. 0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58764296/

相关文章:

javascript - 如何实现自动滚动以跟随我的 div

javascript - 使用expo Camera SDK时,Undefined不是一个对象_expo.camera.constant

javascript - 发出警报时,Sweet alert 2 未显示为模态

javascript - 我怎样才能获得甜蜜警报弹出消息内容的值(value)?

Angularjs 变量值第一次使用 sweetAlert 时未更新,成功

javascript - 如何在 react js中换行后使文本对齐

javascript - 变量存储在哪里?

javascript - Sweetalert 延迟弹出窗口打开

javascript - 中控智慧 PHP/Javascript SDK

javascript - SweetAlert2 蹩脚文本