我在我的组件中收到此错误:
解析错误:意外的标记,预期的“,”
import React from 'react';
import logo from '../../Images/Logo.svg';
class Simulate extends React.Component{
render(){
return(
this.state.wentWrong?
(<div className="went-wrong-box">
<div className="went-wrong-title">
<div className="went-wrong-title__img">
<img src={logo} alt="Logo">
</div>
</div>
</div>)
:
(<div>
Other Content
</div>)
)
}
}
我很确定图像标签中的问题,虽然 src 中使用的标志已经导入,如果我用字符串替换 src 中的标志也会发生这种情况,但是如果我删除了图像,它会起作用:
return(
this.state.wentWrong?
(<div className="went-wrong-box">
<div className="went-wrong-title">
<div className="went-wrong-title__img">
</div>
</div>
<div>)
:
(<div>
Other Content
</div>)
)
提前致谢
您忘记关闭您的<img>
和最后一个<div>
标签。
(<div className="went-wrong-box">
<div className="went-wrong-title">
<div className="went-wrong-title__img">
<img src={logo} alt="Logo" /> // <- close this
</div>
</div>
</div>) // <- close this
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句