const App = () =>{
const condition1 = true
const condition2 = false
return (
<div>
{condition1 || condition2 && <h1>condition met</h1>}
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
上面的代码只关心条件2,条件1被忽略。有没有办法在我的 jsx 中使用 OR 运算符?我也尝试浏览此https://reactjs.org/docs/conditional-rendering.html但找不到我要找的东西。