下午好,我正在使用SweetAlert显示通知,查看官方的SweetAlert文档,他们显示了一些示例,例如显示图像,但我想要做的是显示一个youtube视频。
Swal.fire({
title: 'Sweet!',
text: 'Modal with a custom image.',
imageUrl: 'https://unsplash.it/400/200',
imageWidth: 400,
imageHeight: 200,
imageAlt: 'Custom image',
})在SweetAlert上播放Youtube视频的任何建议。
我做过的一些例子是用iframe嵌入视频:
<iframe width="560" height="315" src="https://www.youtube.com/embed/d_elXY2Lcfk" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>但我只是想通过放置路径来查看视频。
发布于 2021-01-23 10:08:16
在文档中,您可以使用自定义html作为警报正文
Swal.fire({
title: '<strong>HTML <u>example</u></strong>',
icon: 'info',
html:
'<iframe width="560" height="315" src="https://www.youtube.com/embed/d_elXY2Lcfk" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>',
showCloseButton: true,
showCancelButton: true,
focusConfirm: false,
confirmButtonText:
'<i class="fa fa-thumbs-up"></i> Great!',
confirmButtonAriaLabel: 'Thumbs up, great!',
cancelButtonText:
'<i class="fa fa-thumbs-down"></i>',
cancelButtonAriaLabel: 'Thumbs down'
})https://stackoverflow.com/questions/65854871
复制相似问题