首页 > 解决方案 > 在 REACT 中从 cyrptoicons 导入 SVG 时遇到问题

问题描述

我是 REACT 的新手,现在正在玩项目,只是为了提高我的技能。

问题是我无法从这个cryptoicons.co网站导入图标。当我使用此包“https://styled-icons.js.org/”使用样式化图标时,我在另一个项目中取得了成功。

它在github上说

You can then import the icons from ./node_modules/cryptocurrency-icons, for example ./node_modules/cryptocurrency-icons/svg/color/kmd.svg.

我已经尝试过了,但我根本无法让它工作。导入时,我将图标作为对象返回,但我需要将其渲染为 SVG

{src: "/_next/static/image/node_modules/cryptocurrency-ic…g/black/AAVE.e6445d0682c7e011efb864fbefdc5239.svg", height: 32, width: 32}

高度:32 src:“/_next/static/image/node_modules/cryptocurrency-icons/svg/black/AAVE.e6445d0682c7e011efb864fbefdc5239.svg”宽度:32 原型:对象

如果有人可以朝正确的方向戳我,那将是我知识上的空白,这将很有帮助

我试过这个来渲染图标没有成功

<svg src={icon.src}></svg>

标签: reactjsnext.js

解决方案


推荐阅读