错误页面
公共组件
const Errors = (props)=>{const {errors} = propsif(errors){return (<ul className="error-messages">{Object.keys(errors).map(key=>{return (<li key={key}>{key} : {errors[key]}</li>)})}</ul>)}else{return null}}export default Errors
注册页面
import { PureComponent } from 'react'import { Link } from 'react-router-dom'import Errors from '../../components/Errors'class Regist extends PureComponent {render() {return (<div className=' container page'><div className='row'>{/* 注册内容 */}<div className='col-md-6 offset-md-3 col-xs-12'><h1>注册</h1>{/* 重定向登录 */}<p className='text-xs-center'><Link to='/login'>有账号直接登录?</Link></p>{/* 错误提示 */}<Errors errors={errors}/><form><fieldset><fieldset className='form-group'><inputclassName='form-control form-control-lg'type='text'placeholder='用户名称'/></fieldset><fieldset className='form-group'><inputclassName='form-control form-control-lg'type='email'placeholder='用户邮箱'/></fieldset><fieldset className='form-group'><inputclassName='form-control form-control-lg'type='password'placeholder='用户密码'/></fieldset><buttonclassName='btn btn-lg btn-primary pull-xs-right'type='submit'>注册</button></fieldset></form></div></div></div>)}}export default Regist;
登录页面
import { PureComponent } from 'react'import { Link } from 'react-router-dom'import Errors from '../../components/Errors'class Login extends PureComponent {render() {return (<div className=' container page'><div className='row'>{/* 登录内容 */}<div className='col-md-6 offset-md-3 col-xs-12'><h1>登录</h1>{/* 重定向登录 */}<p className='text-xs-center'><Link to='/regist'>没账号直接注册?</Link></p>{/* 错误提示 */}<Errors errors={errors}/><form><fieldset><fieldset className='form-group'><inputclassName='form-control form-control-lg'type='email'placeholder='用户邮箱'/></fieldset><fieldset className='form-group'><inputclassName='form-control form-control-lg'type='password'placeholder='用户密码'/></fieldset><buttonclassName='btn btn-lg btn-primary pull-xs-right'type='submit'>登 录</button></fieldset></form></div></div></div>)}}export default Login;
