onClick没有在反应应用程序中使用hapi-react-views启动

时间:2018-02-17 08:55:25

标签: javascript reactjs hapijs

onClick按钮未在我的应用中触发。我正在使用ReactHapi.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;

0 个答案:

没有答案