JavaScript/react/条件渲染:修订间差异
来自康健生活
| 第6行: | 第6行: | ||
if (condition) return <Component />; | if (condition) return <Component />; | ||
else return null; | else return null; | ||
}</syntaxhighlight> | |||
== 三目运算符 == | |||
<syntaxhighlight lang="javascript"> | |||
function render() { | |||
return condition ? <Component /> : null; | |||
}</syntaxhighlight> | }</syntaxhighlight> | ||