React中条件渲染的示例分析-成都快上网建站

React中条件渲染的示例分析

 ); } class Page extends React.Component {   constructor(props) {  super(props);  this.state = {showWarning: true}  this.handleToggleClick = this.handleToggleClick.bind(this);  }  handleToggleClick() {  this.setState(prevState => ({  showWarning: !prevState.showWarning  }));  }  render() {  return (  
      {this.state.showWarning ? 'Hide' : 'Show'}    
 );  } } ReactDOM.render(   ,  document.getElementById('root') );

看完了这篇文章,相信你对“React中条件渲染的示例分析”有了一定的了解,如果想了解更多相关知识,欢迎关注创新互联行业资讯频道,感谢各位的阅读!


分享名称:React中条件渲染的示例分析
网页路径:http://kswjz.com/article/jechse.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流