I can't modify my SVG component in my React Application

前端 未结 3 492
耶瑟儿~
耶瑟儿~ 2021-01-28 23:27

I have been trying to fill the color of an SVG component in React, but it won\'t work.

I\'ve tried using an image tag to React. However, I read on the React docs that CS

3条回答
  •  长情又很酷
    2021-01-28 23:39

    Most common case is that .svg file is converted/edited or not properly exported, without that file the easiest way to change e.g. color is to open that file in any text/code editor, copy code without xml tag so from svg tag..to closing /svg tag and paste directly into code.

    Then you can easly style whole element or some parts of it e.g.

    .yourSvgWrapperDivClass svg g {
        fill: #0000FF;
    }
    

    You can also refer directly to some elements of the svg file/code (just inspect it) and try style g/path or rect elements.

提交回复
热议问题