【问题标题】:referencing images in SweetAlert2 modals in vue在 vue 中引用 SweetAlert2 模态中的图像
【发布时间】:2021-01-13 06:18:03
【问题描述】:

我有一个 sweetAlert2 模态,我想在其中使用一个图像,但要么我引用这样的 img src="./assets/img/cry.png" 或 src="../assets/img/cry.png" 它不会显示,但在 vue 的其他部分,这个 src 地址工作正常,我应该如何引用它在 SweetAlert2 中?

 this.$swal({
 title: '<div style="font-weight:bold;">sorry</div>',
 icon: 'error',
 confirmButtonText: 'Cool',
 position: 'top',
 backdrop: false,
 html:'<img  src="../assets/img/cry.png" style="width:128px;height:128px;">',
 })

【问题讨论】:

    标签: vue.js sweetalert2


    【解决方案1】:

    这样解决的:

    const imagePath = require("@/assets/img/cry.png");
    
    this.$swal({
    title: '<div style="font-weight:bold;">sorry</div>',
    showConfirmButton: false,
    backdrop: false,
    imageUrl: imagePath,
    imageWidth: 100,
    imageHeight: 100,
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-13
      相关资源
      最近更新 更多