【问题标题】:svgo removeAttrs how to specify attrs to removesvgo removeAttrs 如何指定要删除的属性
【发布时间】:2017-04-21 09:33:30
【问题描述】:

我已将 removeAttrs 设置为 true,我想删除所有填充和颜色:

{
    loader: 'svgo-loader',
    options: {
      plugins: [
        { removeNonInheritableGroupAttrs: true },
        { collapseGroups: true },
        { removeAttrs: true },
      ],
    },
  },

但我不知道如何在其中指定要删除的 attrs...

【问题讨论】:

  • removeUselessStrokeAndFill ??
  • 没有删除无用的笔画和填充我试过..
  • 请提供完整代码
  • 这很酷:) :)
  • 有人能告诉我如何在命令行上使用它吗?我想摆脱一堆 SVG 文件中的许多“禁止”数据名称属性。 “svgo . enable=removeAttrs 数据名称”不起作用。

标签: javascript svg loader


【解决方案1】:

我是这样解决的:

{
  loader: 'svgo-loader',
  options: {
    plugins: [
      { removeNonInheritableGroupAttrs: true },
      { collapseGroups: true },
      { removeAttrs: { attrs: '(fill|stroke)' } },
    ]
  }
}

【讨论】:

  • 现在我想使用这段代码来为不同的 svgs 定义我的风格。简单地说,我想从包含名称 Multicolor 的 svg 中消除填充和描边。名称如:callIcon.Multicolor.svg.
  • 您是否找到了保留多色特定图标的解决方案?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-03-31
  • 1970-01-01
  • 1970-01-01
  • 2023-03-26
  • 2011-10-23
  • 2011-10-23
  • 2010-10-20
相关资源
最近更新 更多