【发布时间】:2023-03-14 14:34:01
【问题描述】:
我似乎在我的 React/Ionic 应用程序中加载 SVG 时遇到了问题。我通过 OpenWeatherMap 获取天气并通过 weather?.weather[0].icon 访问要使用的图标我正在使用以下图标包 https://github.com/basmilius/weather-icons 但是当我插入上面的内容时,它不会呈现我正在使用的 SVG 图标
<img src={`../images/${weather?.weather[0].icon}.svg`}/> 但它一直显示它,就像图像丢失一样。
图片在与本页同根目录的images目录中
Page is in src/pages
Image is in src/images
有人对为什么会这样有任何提示吗?
包中的一个示例 SVG 是:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g><circle cx="32" cy="32" r="11.64" fill="#f4a71d"/><path fill="none" stroke="#f4a71d" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" d="M32 15.71V9.5M32 54.5v-6.21M43.52 20.48l4.39-4.39M16.09 47.91l4.39-4.39M20.48 20.48l-4.39-4.39M47.91 47.91l-4.39-4.39M15.71 32H9.5M54.5 32h-6.21"/><animateTransform attributeName="transform" dur="45s" from="0 32 32" repeatCount="indefinite" to="360 32 32" type="rotate"/></g></svg>
【问题讨论】:
标签: javascript reactjs typescript ionic-framework svg