You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

22 lines
546 B

// 条件渲染
// 技术方案:三元表达式(常用)、逻辑 && 运算
// 1. 三元表达式:满足条件才渲染一个 span 标签
var flag = true
// 2. 逻辑 && 运算
function App() {
return (
<div className="App">
{ flag ? <span>this is span</span> : null}
{/* 如果模板比较复杂,可以使用()进行包裹 */}
{ flag ? (<div><span>this is span</span></div>) : null}
{ false && <span>666666666</span>}
{ true && <span>666666666</span>}
</div>
);
}
export default App;