[英]Tell me how to handle objects before sending axios
I'm using React.我正在使用反应。
Raise the child object to the parent.将子 object 抚养到父级。 I want to delete the unnecessary value and send it.
我想删除不必要的值并发送它。
const before = {
address_check: true,
loan_check: true,
oneroom_disable: true,
info: {
age: 13,
name: gogo,
item: [1,2,3]
},
face: {
life: [1,2,3]
}
};
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
const after = {
address_check: true,
age: 13,
name: gogo,
item: [1,2,3]
};
How can I change the status from before to after?如何将状态从之前更改为之后?
You can create object from other object like below:-您可以从其他 object 创建 object,如下所示:-
const after = {
address_check: before.address_check,
age: before.info.age,
name: before.info.name,
item: before.info.item
}
You can do something like this:你可以这样做:
// Original data
const before = {
address_check: true,
loan_check: true,
oneroom_disable: true,
info: {
age: 13,
name: gogo,
item: [1,2,3]
},
face: {
life: [1,2,3]
}
};
// Destructure required fields
const {address_check, info: {age, name, item}} = before;
// Put them together for your new object
const after = {
address_check, age, name, item
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.