0

我想在文本字段中使用SweetAlert2显示图像。我相信 SweetAlert 只是返回和反对。这是它的样子:

swal({
  title: 'Title',
  text: 'text',
  type: 'success'
})

这些中的每一个通常都带有一个字符串。我想要做的是在文本字段中显示和图像。我试过做text: (<img src="image_src" />),但这不起作用,它只是显示[ojbect Object]在警报中。

我应该注意到这一点,但我也在 src 中为图像添加了一个变量。所以我需要这个以某种方式工作

<img src={`${image_url}`} />

如果您需要更多代码,请告诉我!

4

1 回答 1

0

感谢@helb 的有用评论,我发现而不是使用

swal({
  title: 'Title',
  text: 'text',
  type: 'success'
})

我需要这样做:

swal({
  title: 'Title',
  html: `<img src='${image_url}'/>`,
  type: 'success'
})
于 2017-10-17T15:23:38.583 回答