【发布时间】:2021-06-07 10:09:51
【问题描述】:
我尝试使用result.dismiss、result.isDismissed 和result.isDenied,但我似乎无法足够具体地检查用户是否在 swal 消息之外单击。
这是我的代码:
Swal.fire({
position: "top-end",
title: `${name} successfully added to cart!`,
icon: "success",
showCancelButton: true,
cancelButtonText: "Continue shopping",
cancelButtonColor: "green",
confirmButtonText: "Go To Cart",
confirmButtonColor: "blue",
}).then((result) => {
if (result.isConfirmed) history.push("/cart");
else if (location.pathname == "/" && !result.dismiss)
history.push("/products");
});
谢谢!
【问题讨论】:
-
根据你使用的版本,Swal提供了“allowOutsideClick”选项,不知道是不是和你的问题有关?
-
不相关但感谢您的评论:)
-
好的,抱歉打扰了大声笑:)