代码之家  ›  专栏  ›  技术社区  ›  Bumboobee

有没有办法将Pdf放入Swal模型中?

  •  0
  • Bumboobee  · 技术社区  · 3 年前

    我正在做一个按钮,当用户点击时,打开一个游泳池。。。问题是,我怎样才能在swal模式中放置Pdf视图,而不将用户发送到另一个页面?

    可以使用Sweet Alert库来实现吗?我该怎么做?

    1 回复  |  直到 3 年前
        1
  •  0
  •   Shura16    3 年前

    您可以在SweetAlert中添加一些html代码。

    Swal.fire({
      title: '<strong>HTML <u>example</u></strong>',
      icon: 'info',
      html:
        'You can use <b>bold text</b>, ' +
        '<a href="//sweetalert2.github.io">links</a> ' +
        'and other HTML tags',
      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'
    })
    

    然后尝试添加带有嵌入的pdf,例如:

    <embed src="files/Brochure.pdf" type="application/pdf" width="100%" height="600px" />
    

    参考资料:

    https://sweetalert2.github.io/

    https://www.codexworld.com/embed-pdf-document-file-in-html-web-page/