react js - use svg linear gradient not working

落花浮王杯 提交于 2019-12-03 16:39:12

in react the attributes form of linear gradient are a bit diffrent and supposed to be like this:

<linearGradient id="linear-gradient" gradientUnits="userSpaceOnUse" x1="1041.6901" y1="169.485" x2="1383.9301" y2="169.485" gradientTransform="matrix(1 0 0 -1 -761.14 398.97)">
      <stop offset="14%" stopColor="#2f343b" stopOpacity="0%"/>
      <stop offset="43%" stopColor="#337082" stopOpacity="41%"/>
      <stop offset="67%" stopColor="#369fb9" stopOpacity="73%"/>
      <stop offset="79%" stopColor="#37b1cf" stopOpacity="85%"/>        </linearGradient>

its mean that the syntax should be from stop-color => stopColor

offset should be in percentage

ReactJs + svg

For others coming here later, style={{fill:'url(#linear-gradient)'}} is unnecessary for just one or a mere few styles. Instead, simplify to fill="url(#linear-gradient)". The same applies to other common SVG styling like stroke="url()".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!