Svg defs encapsulation

前端 未结 1 1599
孤独总比滥情好
孤独总比滥情好 2021-01-21 14:24

I\'m trying to encapsulate an SVG line with an arrowhead at the end without any global ids in a React component, (but the question itself has nothing to do with React).

相关标签:
1条回答
  • 2021-01-21 14:31

    You have a few choices:

    1. Pull the marker definition(s) out into a static SVG that is referenced by all LinkComponents, or

    2. Generate a random, unique id each time.

    3. Add the colour to the id, so even if you have duplicate marker definitions, it doesn't matter which one is referenced:

      id="arrow-{color}"
      
    4. Don't use markers. Draw the arrowhead yourself.

    0 讨论(0)
提交回复
热议问题