首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在SweetAlert中显示视频

在SweetAlert中显示视频
EN

Stack Overflow用户
提问于 2021-01-23 09:28:00
回答 1查看 941关注 0票数 2

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

SweetAlert2

代码语言:javascript
复制
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嵌入视频:

代码语言:javascript
复制
<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>

但我只是想通过放置路径来查看视频。

EN

回答 1

Stack Overflow用户

发布于 2021-01-23 10:08:16

在文档中,您可以使用自定义html作为警报正文

代码语言:javascript
复制
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'
})
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65854871

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档