设置表单

  1. class SettingForm extends PureComponent{
  2. // state
  3. constructor(props){
  4. super(props)
  5. const {currentUser} = props
  6. this.state={
  7. avatar:(currentUser && currentUser.avatar) || '默认头像地址',
  8. username:(currentUser && currentUser.username) || '',
  9. bio:(currentUser && currentUser.bio) || '',
  10. email:(currentUser && currentUser.email) || ''
  11. }
  12. }
  13. render(){
  14. const {avatar,username,bio,email} =this.state
  15. return (
  16. <form>
  17. <fieldset>
  18. <fieldset className='form-group'>
  19. <input
  20. className='form-control form-control-lg'
  21. type='text'
  22. placeholder='头像URL'
  23. value={avatar}
  24. />
  25. </fieldset>
  26. <fieldset className='form-group'>
  27. <input
  28. className='form-control form-control-lg'
  29. type='text'
  30. placeholder='用户名称'
  31. value={username}
  32. />
  33. </fieldset>
  34. <fieldset className='form-group'>
  35. <input
  36. className='form-control form-control-lg'
  37. type='email'
  38. placeholder='用户邮箱'
  39. value={email}
  40. />
  41. </fieldset>
  42. <fieldset className='form-group'>
  43. <textarea
  44. className='form-control form-control-lg'
  45. rows='8'
  46. placeholder='用户简介'
  47. value={bio}
  48. />
  49. </fieldset>
  50. {/* 修改用户密码:新密码 */}
  51. <fieldset className='form-group'>
  52. <input
  53. className='form-control form-control-lg'
  54. type='password'
  55. placeholder='设置新密码'
  56. />
  57. </fieldset>
  58. <button
  59. className='btn btn-lg btn-primary pull-xs-right'
  60. type='submit'
  61. >
  62. 更新设置
  63. </button>
  64. </fieldset>
  65. </form>
  66. )
  67. }
  68. }

设置页面

  1. class Setting extends PureComponent {
  2. render() {
  3. return (
  4. <div className='settings-page'>
  5. <div className='container page'>
  6. <div className='row'>
  7. <div className='col-md-6 offset-md-3 col-xs-12'>
  8. <h1 className='text-xs-center'>设置</h1>
  9. {/* 错误提示 */}
  10. <Errors errors={errors}/>
  11. {/* 修改用户信息 */}
  12. <SettingForm currentUser={currentUser}/>
  13. <hr />
  14. {/* 退出 */}
  15. <button
  16. className='btn btn-outline-danger'>
  17. 退出
  18. </button>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. )
  24. }
  25. }