印刷< svg>内部< img>关于反应
您好,我试图用SVG制作小应用程序。 我有一个返回SVG和其他信息的请求。
[
{
"svg": "<svg \n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"h-6 w-6\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n>\n <path \n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M11 19l-7-7 7-7m8 14l-7-7 7-7\"\n />\n</svg>",
}
]
获得SVG值
useEffect(() => {
getSummaryWarnings().then((res) => {
setData(res.data);
});
}, []);
打印IMG
{data.map((item) => (
<img
tabIndex={0}
key={item._id}
className="warning-sign"
alt={item.title}
src={item.svg}
onClick={() => tooglePopup(item)}
/>
))}
,但我看不到我的SVG。 任何帮助。
Hello I am trying to make small app with svgs.
I have a request that returns svg and other informations.
[
{
"svg": "<svg \n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"h-6 w-6\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n>\n <path \n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M11 19l-7-7 7-7m8 14l-7-7 7-7\"\n />\n</svg>",
}
]
Getting svg value
useEffect(() => {
getSummaryWarnings().then((res) => {
setData(res.data);
});
}, []);
Printing the img
{data.map((item) => (
<img
tabIndex={0}
key={item._id}
className="warning-sign"
alt={item.title}
src={item.svg}
onClick={() => tooglePopup(item)}
/>
))}
But i cant see my svg.
Any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一个替代解决方案:
我们可以用这个打印SVG
I found an alternative solution:
We can print svg with this