我似乎在试图听一个事件时做错了什么。我已在输入框中发出警报,但即使这样似乎也无法正常工作。可能是什么原因?
import React from 'react';
class PersonalDetails extends React.Component {
constructor(props) {
super(props);
console.log('PersonalDetails constructor......');
console.log(props);
this._handleTextChange = this._handleTextChange.bind(this);
this._handleSave = this._handleSave.bind(this);
}
_handleTextChange(event) {
this.props.onChange(event);
}
_handleSave(event) {
this.props.onSave(event);
}
render() {
return (
<div >
<h2 className="title" >Your Contact Details </h2>
<h2> Your name </h2>
<label for="Firstname">First Name: </label>
<input name="firstname"
value={this.props.firstname}
type="text"
onChange={this._handleTextChange}>
</input>
<input
type="image"
alt="Confirm"
name="confirm"
src="/myaccount/btnConfirm.gif"
//onClick={this._handleSave}/>
onClick={function(){alert("Hello World!")}}/>
<br/>
<br/>
<div className="line"></div>
</div>
);
}
}
export default PersonalDetails;