react组件中新添加了部分DOM为什么显示不出来

0 0 javascript react.js html
error(*)
error(*)

声望值:177 0人

2019-02-03 11:57:20 提问

关注 0关注

收藏 0收藏, 100浏览

import React from 'react';
import AddCharacterStore from '../stores/AddCharacterStore';
import AddCharacterActions from '../actions/AddCharacterActions';

class AddCharacter extends React.Component {
constructor(props) {

super(props);
this.state = AddCharacterStore.getState();
this.onChange = this.onChange.bind(this);

}

componentDidMount() {

AddCharacterStore.listen(this.onChange);

}

componentWillUnmount() {

AddCharacterStore.unlisten(this.onChange);

}

onChange(state) {

this.setState(state);

}

handleSubmit(event) {

event.preventDefault();

var name = this.state.name.trim();
var gender = this.state.gender;
var wins = this.state.wins;

if (!name) {
  AddCharacterActions.invalidName();
  this.refs.nameTextField.focus();
}

if (!wins) {
  AddCharacterActions.invalidWins();
}

if (!gender) {
  AddCharacterActions.invalidGender();
}

if (name && gender && wins) {
  AddCharacterActions.addCharacter(name, gender, wins);
}

}

render() {

return (
  
Add Character

Character Name {this.state.helpBlock}
test !

Win Vote

{this.state.helpBlock}

Female
Male
Submit

);

}
}

export default AddCharacter;

请先 登录 后评论

1个回答

注册新账号

悬赏追问
10
  • 10
  • 20
  • 50
  • 100
  • 200
  • 输入数值
发布追问