【发布时间】:2019-12-09 19:20:57
【问题描述】:
我正在尝试检查 JSX,如果我的价格变量大于 0,并且如果它显示价格框...我似乎无法正确使用语法。
export default ({ result }) => {
const id = result.id || {};
const price = result.price || {};
return (
<Col xs={12} md={4}>
<li className="sui-result product">
<a
id="offre_row_3"
href={"https://www.cliiic.com/offre.php?id=" + id.raw}
className="col-xs-4"
ng-repeat="forfait in forfaits"
style={{ padding: "0px", textDecoration: "none" }}
>
{/*MORE STUFF*/}
{if(price.raw > 0) {
return (
<div
id={"price_" + id.raw}
style={{
clear: "both",
margin: "5px",
float: "right",
height: "27px",
lineHeight: "27px",
fontSize: "15px",
textAlign: "center",
fontWeight: "bold",
color: "#FFF",
backgroundColor: "rgba(0,0,0,0.5)",
position: "relative",
display: "block",
top: "99px",
padding: "0 10px",
width: "97px"
}}
>
<span className="currency">{price.raw}</span>+" $"
);}}
{/*MORE STUFF*/}
</a>
</li>
</Col>
);
};
我发现的 IF/ELSE 语句的每个示例都尝试使用 render() 函数,但此时我已经在渲染中,并且 IF 运算符使应用程序崩溃。
返回的错误是:
SyntaxError
/src/ResultView.js: Unexpected token (96:15)
94 | </div>
95 |
> 96 | {if(price.raw > 0) {
| ^
97 | return (
98 | <div
【问题讨论】: