如何以编程方式将图像插入富含闪电的文本中?

发布于 2025-01-22 15:39:24 字数 468 浏览 0 评论 0原文

我具有Base64格式的图像,我想将图像数据明确推入我的闪电输入富文本中。有什么办法吗?

我的代码看起来像这样:

<lightning-input-rich-text value={body} label="EmailBody" placeholder="Email Body" >
            </lightning-input-rich-text>

在我的JS控制器中,我正在尝试执行此操作

this.body = this.filesUploaded[0]['VersionData']

// this.filesuploaded [0] ['versionData']代表base64格式数据

,而不是显示图像我的闪电输入富含text show base64 ex的字符串:('ivborw0kggoaaaa ....')

I have an image in base64 format and I want to push the image data explicitly into my lightning-input-rich-text. Is there any way?

My code looks like this:

<lightning-input-rich-text value={body} label="EmailBody" placeholder="Email Body" >
            </lightning-input-rich-text>

and in my JS Controller I am trying to do this

this.body = this.filesUploaded[0]['VersionData']

// this.filesUploaded[0]['VersionData'] represent the base64 format data

Instead of showing the image My lightning-input-rich-text show base64 string for ex: ('iVBORw0KGgoAAAA....')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一萌ing 2025-01-29 15:39:24

您将需要确保您的文本控件内容添加了IMG HTML标签。因此,在您的JS文件中,您的身体变量必须设置为代表创建使用base64作为其源的IMG标签所需的HTML代码的字符串,例如:

this.body = '<img src="data:image/png;base64,' + this.filesUploaded[0]['VersionData'] + '" />';

You would need to make sure your are adding an IMG html tag to the contents of your rich text control. So, in your js file, your body variable must be set to a string that represents the html code needed to create an IMG tag that uses base64 as its source, e.g.:

this.body = '<img src="data:image/png;base64,' + this.filesUploaded[0]['VersionData'] + '" />';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文