微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 SweetAlert 中显示视频

如何解决在 SweetAlert 中显示视频

下午好,我正在使用 SweetAlert 显示通知,查看官方 SweetAlert 文档中显示的一些示例,例如显示图像,但我想要做的是显示 youtube 视频。

SweetAlert2

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>

但我希望通过放置我可以看到视频的路径来实现。

解决方法

在文档中,您可以使用自定义 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'
})

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?