前端学习(2229):react条件渲染实现登录
生活随笔
收集整理的這篇文章主要介紹了
前端学习(2229):react条件渲染实现登录
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
index.js
import React from 'react'; import ReactDOM from 'react-dom';function UserGree(props) {return ( < h1 > 歡迎登陸 < /h1>)}function UserLogin(props) {return ( < h1 > 請先登陸 < /h1>)}class ParentCom extends React.Component {constructor(props) {super(props)this.state = {isLogin: true}}render() {if (this.state.isLogin) {if (this.state.isLogin) {return ( < UserGree > < /UserGree>)}else {return ( < UserLogin > < /UserLogin>)}}}}//console.log("這是渲染函數(shù)")ReactDOM.render( < ParentCom / > , document.querySelector("#root"))運行結(jié)果
總結(jié)
以上是生活随笔為你收集整理的前端学习(2229):react条件渲染实现登录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 17存储器的分类
- 下一篇: 自己动手写操作系统(五)