react中使用三元表达式

class Hello extends Component{
    constructor(props){
        super(props);
        this.state = {
            now:Date.now(),
            key:true
        }
    }
    render(){
        return(
            <div>
                {
                    this.state.key
                        ? <p>aaa</p>
                        : <p>bbb</p>
                }
            </div>
        )
    }
}

随机浏览