如何在SVG中继承笔划颜色?(不是填充,而是笔划颜色)

如何在SVG中继承笔划颜色?(不是填充,而是笔划颜色),svg,colors,stroke,Svg,Colors,Stroke,我有一个.SVG,在这里我用调用它。一切都很好,但我想动态地为我的SVG设置不同的笔划颜色(而不是填充颜色…),比如 正确地说,而且,用作图像元素的svg具有新的图像上下文,因此它不使用文档的样式,而内联svg元素使用它们 因此,以下示例有效: svg.red{ 颜色:红色; } 图像无法从宿主文档继承内容。您可以将标记内联。 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink

我有一个.SVG,在这里我用
调用它。一切都很好,但我想动态地为我的SVG设置不同的笔划颜色(而不是填充颜色…),比如

正确地说,而且,用作图像元素的svg具有新的图像上下文,因此它不使用文档的样式,而内联svg元素使用它们

因此,以下示例有效:

svg.red{
颜色:红色;
}

图像无法从宿主文档继承内容。您可以将标记内联。
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" height="100" width="100">
    <path d="M20 10 H90 V80" fill="transparent" stroke="currentColor" stroke-width="20" stroke-linecap="round"></path>
    <path d="M10 90 L100 0" fill="transparent" stroke="currentColor" stroke-width="20" stroke-linecap="round"></path>
</svg>
<img src="/image/arrow.svg" alt="Arrow" style="color:red">