我正在尝试更新React应用中的状态
state = {
pickupAddress: {
country: '',
city: '',
zipCode: '',
street: '',
},
deliveryAddress: {
country: '',
city: '',
zipCode: '',
street: '',
},
parcel: {
type: '',
height: '',
width: '',
length: '',
weight: '',
quantity: '',
},
};
我面临的问题是,例如,我无法用e.target.pickupAddress.city
到达对象内部。
这是我的onChange方法
onChange = (e) => this.setState({[
e.target.pickupAddress.country]: e.target.pickupAddress.country
});