react-bootstrap
onChange
形式。但是我无法使用
onChange公司
. 我只能得到值
onSubmit
但这无助于我想要达到的目标。
所以当我收到道具时,我把数据设置成这样的对象
componentWillReceiveProps() {
const { login } = this.props;
console.log("Joker ", login.userInformation);
const data = {
"name" : login.userInformation && login.userInformation.name,
"address" : {
"address" : login.userInformation && login.userInformation.address.address,
"cep" : login.userInformation && login.userInformation.address.cep,
"city" : login.userInformation && login.userInformation.address.city,
"country" : login.userInformation && login.userInformation.address.country
}
}
this.setState({
initialData: data
})
}
理想情况下,我想为你实现这样的目标
onChange公司
handleSubmit = event => {
const { updateUserInfo, userPictureUpload, login } = this.props;
const userInfoAddress = login.userInformation !== null ? login.userInformation.address : '';
const form = event.currentTarget;
event.preventDefault();
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
} else {
const profileData = {
"name" : event.target.formUserName.value,
"address" : {
"address" : event.target.formAddress.value,
"cep" : event.target.formPostalCode.value,
"city" : event.target.formCity.value,
"country" : this.state.country === '' ? userInfoAddress.country : this.state.country
}
}
var eq = JSON.stringify(this.state.initialData) === JSON.stringify(profileData);
if (!eq) {
updateUserInfo(profileData);
} else {
alert("same");
}
}
};
但是我无法使用onChange获取字段的值,比如
event.target.formAddress.value
. 如何获取现场数据
onChange公司