The `style` attribute expects a mapping from style attributes to values
P粉817354783
P粉817354783 2023-08-15 15:37:44
0
1
413
<p>While creating a front and back image slider using React, I encountered this error. I don't know if I need to import it but unfortunately it is an external file. Any tips and suggestions would be greatly appreciated</p> <pre class="brush:php;toolbar:false;"><div class="scroller scroller-top"> <svg class="scroller__thumb" xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><polygon points= "0 50 37 68 37 32 0 50" style="fill:rgb(24,24,62)"/><polygon points="100 50 64 32 64 68 100 50" style="fill:rgb(24 ,24,62)"/></svg> </div></pre> <p>I expected to see the SVG icon, but instead an error was thrown as described above</p>
P粉817354783
P粉817354783

reply all(1)
P粉276064178

You can add the fill attribute directly on the polygon as follows:

<div className="scroller scroller-top">
  <svg
    className="scroller__thumb"
    xmlns="http://www.w3.org/2000/svg"
    width="100"
    height="100"
    viewBox="0 0 100 100"
  >
    <polygon points="0 50 37 68 37 32 0 50" fill="rgb(24,24,62)" />
    <polygon points="100 50 64 32 64 68 100 50" fill="rgb(24,24,62)" />
  </svg>
</div>

Bonus: If you are using React, the class attribute should be className.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!