简体   繁体   English

React SVG 组件:6:134 错误解析错误:意外标记,预期为“}”

[英]React SVG Component: 6:134 error Parsing error: Unexpected token, expected "}"

import React, { Component } from "react"; export default class Logo extends Component { render() { return ( <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 615 615"><defs><style>.cls-1{stroke:#fff;stroke-miterlimit:10;stroke-width:4px;}.cls-2{fill:#f2f2f2;}</style></defs><title>vision-octo-bw</title><g id="octo-drop"><polygon class="cls-1" points="450.68 546.99 185.11 547 52.32 317.01 185.09 87.01 450.67 87 583.47 316.99 450.68 546.99"/><path class="cls-2" d="M318.87,154c-61.78,91.83-64.25,97.12-77,115-24.86,35-68,112.88-6.57,174.31s136.77,33.83,162.92,3.83c28.13-32.27,60-82.76-2.16-176.17C331.37,173.6,325.2,164.31,318.87,154Z"/></g></svg> ); } }

Change your style from this从此改变你的风格

<style>
 .cls-1{stroke:#fff;stroke-miterlimit:10;stroke-width:4px;}
 .cls-2{fill:#f2f2f2;}
</style>

to like this喜欢这个

<style>
  {`.cls-1{stroke:#fff;stroke-miterlimit:10;stroke-width:4px;}`}
  {`.cls-2{fill:#f2f2f2;}`}
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM