我有以下 SweetAlert 代码..
<script type="text/javascript" charset="utf-8">
$('.patient-details').click(function(e) {
e.preventDefault();
var name = $(this).attr('data-name');
var gender = $(this).attr('data-gender');
var age = $(this).attr('data-age');
var country = $(this).attr('data-country');
var state = $(this).attr('data-state');
var address = $(this).attr('data-address');
var report = $(this).attr('data-report');
swal({
title: name,
text: "Gender: " + gender +"\n" + "Age: " + age +"\n" + "Country: " + country +"\n" + "State: " + state +"\n" + "Address: " + address +"\n" + "Report: " + report,
confirmButtonColor: "#00B4B4",
imageUrl: "images/avatar/user.png",
});
});
</script>
var 报告是一个链接,我需要在模式中显示该链接。我尝试了 html: true 等,html 不再使用。而是使用内容对象。正如医生所说:
https://sweetalert.js.org/docs/#content
https://sweetalert.js.org/guides/
但我作为一个新手无法理解它。
请求有关如何在模式中显示链接以及如何在新窗口中打开链接的帮助。
Update:由于提供的解决方案不起作用,我使用了另一种使用 html 的方法来解决它。需要删除文本,否则文本将是默认的。代码笔链接:https://codepen.io/pamela123/pen/GOJZgo
找到了这个答案here,所有学分都归于特里斯坦·爱德华兹
const el = document.createElement('div')
el.innerHTML = "Here's a <a href='http://google.com'>link</a>"
swal({
title: "Hello!",
content: el,
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)