简体   繁体   English

如何通过mixin将svg添加到pug?

[英]How to add svg to pug via mixin?

I have a mixin我有一个混音

mixin icon(url)
  svg()
    use(xlink:href=url)

And the code to output以及 output 的代码

 -
   var features = [
      {
        icon: +icon(img/time.svg)
      }
   ]
  each item in features
    +feature(item.icon)

What am I doing wrong?我究竟做错了什么?

Are you wanting something like this?你想要这样的东西吗? I've fixed the indentation, mixin references, and stored the path to the icon as a string.我已经修复了缩进、mixin 引用,并将图标的路径存储为字符串。

mixin icon(url)
  svg
    use(xlink:href=url)

-
  var features = [
    {
      icon: 'img/time.svg'
    }
  ]

each item in features
  +icon(item.icon)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM