javascript - 我怎样才能让 sweet2alert 不再显示消息?
问题描述
如果我单击使用 localstorage,我一直在尝试隐藏此消息,"<span onclick='save()'>Don't Show Again</span>",
但它不起作用。我怎么做?
<script type="text/javascript">
if(localStorage.getItem("DontShow")) {
$("#save").hide();
}
$(document).on("click", "#save", function() {
localStorage.setItem("DontShow", "true");
});
Swal.fire({
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false,
showCancelButton: true,
icon: 'info',
title: 'Title',
html: '<div class="swal-left"><b>Text</b><br>Text</div>',
confirmButtonColor: '#DD6B55',
cancelButtonText: "Close",
confirmButtonText: "<span onclick='save()'>Don't Show Again</span>",
footer: '<a href>Why do I have this issue?</a>'
});
</script>
解决方案
在 swal.fire 函数之后添加这个
.then((result) => {
if (result.isConfirmed)
'function that hides here'
});
推荐阅读
- ruby-on-rails-5 - 与 has_many 一起使用时,accepts_nested_attributes_for 仅显示一条记录
- apache-spark - 将数据框与列名之间包含“-”的列连接时出现问题
- java - Spring Boot 我的 jar 文件在哪里
- html - div标签内的HTML div标签,它的目的是什么?
- elixir - 更新深层嵌套映射中的单个值
- c# - AWS C# 无法弄清楚如何将 zip 流上传到 S3 存储桶
- java - 将动作侦听器添加到静态上下文
- r - 使用 facet wrap 在 ggplot 中排序
- android - 如何在片段加载时将适配器附加到片段中的 recyclerview
- javascript - 如何找到列表中具有相同总和的所有整数组合?