javascript - svgo removeAttrs 如何指定要删除的属性

标签 javascript svg loader

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

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

但我不知道如何指定要删除的属性...

最佳答案

我是这样解决的:

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

关于javascript - svgo removeAttrs 如何指定要删除的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43539086/

相关文章:

javascript - React-ace 编辑器的 onBlur 事件没有返回值

javascript - 检查图像加载失败

html - SVG/SMIL 回流/重绘的性能影响?

c++ - 如何在 C++ 中加载未引用的对象?

javascript - AngularJS 不计算表达式

css - 为什么 CSS 过滤器不适用于 Chrome 中的 SVG 元素?

java - 使用java编辑svg或psd

java - 未考虑 Tomcat 共享加载程序

android - 如何自定义进度加载器?

javascript - 提交隐藏后HTML5输入表单重现