我遇到了一个错误,由于似乎还没有人遇到这种问题,我似乎找不到任何解决方案。
我阅读了create-react-app文档,您可以将SVG文件作为React组件here加载。
我的示例用法如下:
import { ReactComponent as Caret } from '../icons/caret.svg';
//other parts of code
<Caret />
//other parts of code
但是,出现这样的错误:
./src/icons/caret.svg (./node_modules/@svgr/webpack/lib?-prettier,-svgo!./src/icons/caret.svg
const pBabelTransform = async jsCode => new Promise((resolve, reject) => {
^^^^^^
SyntaxError: Unexpected identifier
我的react-scripts
的版本为2.1.3。
任何帮助将不胜感激。