if-else
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isShow:true
}
}
render() {
return (
<div>
{this.Message()}
</div>
)
}
Message(){
if(this.state.isShow){
return (<span>显示</span>)
}else{
return (<span>隐藏</span>)
}
}
}
export default App;
三元
<p>{this.state.isShow?'good':'hello world'}</p>
for map
<div>{this.state.arr.map(item=>{
return (<p>{item}</p>)
})}</div>
</div>