html - 循环插值 SVG 精灵
问题描述
我一直在试图弄清楚如何在循环中插入这些 svg 精灵。html svg < use > 元素的路径缺少一些东西。
环形
each feature, slug in public.feature._data
.feature__wrap
.feature__image
svg
use(xlink:href="/assets/defs.svg#icon-feature-#")
.feature__content
h3.feature__title #{ feature.title }
p.feature__text #{ feature.text }
svg 精灵
<symbol id="icon-feature-1" viewBox='0 0 512 512'>
<desc>Monitor Icon</desc>
<path d="M 10 10 H 90 V 90 H 10 L 10 10"/>
</symbol>
<symbol id="icon-feature-2" viewBox='0 0 512.004 512.004'>
<desc>Cellphone Icon</desc>
<path d="M 10 10 H 90 V 90 H 10 L 10 10"/>
</symbol>
<symbol id="icon-feature-3" viewBox='0 0 64 64'>
<desc>Gear Icon</desc>
<path d="M 10 10 H 90 V 90 H 10 L 10 10"/>
</symbol>
注意:我只是使用了一个随机的 svg <path> 以使其更易于阅读并减少片段上的字符数量
注意2:我已经仔细检查了每个单独的路径,它工作得很好,以便我在我的代码的其他部分中插入的其他精灵没有循环。
解决方案
推荐阅读
- python - 从txt文件在python中创建字典
- python-3.x - 为什么会出现“连接被拒绝”错误
- reactjs - 如何使用 React 正确设置 react-router-dom 链接
- html - 即使未禁用复选框,复选框的标签也显示为灰色 - 如何解决此问题?
- c++ - 用C scanf关闭cin同步的坏处
- compression - 使用 png8 而不是 png24 作为 RGB 高度图
- php - 仅允许在特定日期购买特定 WooCommerce 产品
- sql - 是什么导致 SQL 中缺少右括号错误?
- python - python中的余弦相似度(向量,矩阵)?
- angular - 未找到 MechanicDataCollectionComponent 的组件工厂。你把它添加到@NgModule.entryComponents 了吗?