ruby-on-rails - Ruby-On-Rails qrcode.as_svg 不生成图像
问题描述
在过去的两天里,我一直被这个困住。当我尝试生成我的二维码图像时,我得到了一些奇怪的东西。不管什么格式。例如,当我使用“正常”格式时,它可以工作。
<%= qrcode = RQRCode::QRCode.new("http://github.com/") %> gives me the expect result.
但是,当我这样做时:
<%= svg = qrcode.as_svg( offset: 0, color: "000", shape_rendering: 'crispEdges', module_size: 6, standalone: true ) %>
我得到了一些非常奇怪的东西。我尝试通过正常方式导入图像,将 svg 文件添加到我的资产图像文件中,它工作正常
在此处输入图像描述
知道发生了什么吗?
谢谢
解决方案
您可以尝试使用 html_safe,因为您将 svg 作为文本插入到 html,但我不确定,因为您没有提供太多信息)
<%= svg = qrcode.as_svg( offset: 0, color: "000", shape_rendering: 'crispEdges', module_size: 6, standalone: true ).html_safe %>
或者
<%= qrcode.as_svg( offset: 0, color: "000", shape_rendering: 'crispEdges', module_size: 6, standalone: true ).html_safe %>
推荐阅读
- c# - 在两个 asp 核心 api 之间共享 Jwt 令牌
- json - 谷歌课堂 - 修改附件方法
- python-3.x - 如何在 Python 中获取对象字典表示
- c++ - 如何从子 B 创建子 A 并转换为父级?
- azure - 带有 .NET Core 3.0 的 Azure Web 应用程序失败:找不到 Microsoft.AspNetCore.App
- javascript - Firefox 流式传输两个摄像头
- azure - 1 个 ASB 队列可以转发到多个队列吗?
- php - PHPWord - 找不到类“页脚”
- android - 活动不能转换为接口
- r - 如何在 R 3.6.1 中安装“biotools”?