onClick按钮未在我的应用中触发。我正在使用React
与Hapi.js
服务器。
import * as React from 'react';
var Button=require('react-bootstrap').Button;
var ControlLabel=require('react-bootstrap').ControlLabel;
var FormControl= require('react-bootstrap').FormControl;
var HelpBlock= require('react-bootstrap').HelpBlock;
type Props = { /* ... */ };
type State = {
count: number,
};
class View extends React.Component<Props,State>{
constructor(props: Object ) {
super(props);
this.state = { count: 0, };
}
componentWillMount(){
console.log('componentWillMount');
this.setState({ count: 1, });
}
add(){
console.log('Add');
}
render () {
console.log('render ');
return (
<div>
<div>
<ControlLabel>Address1-{this.state.count}</ControlLabel>
<FormControl type="text" placeholder="" id="address1" name="address1" required/>
</div>
<div>
<Button onClick={this.add}>Add</Button>
</div>
</div>
);
}
}
module.exports = View;