我找不到一种干净的方法来合并两个数组并保留其他字段,即数组对象之间的区别。
const currentForm = [
{
name: "username",
type: "string",
info: "enter username",
value: "test"
},
{
name: "password",
type: "aes",
info: "enter password",
value: "pass"
}
];
const newForm = [
{
name: "username",
type: "string",
info: "enter username"
}
];
合并后我想要这个数组:
const currentForm = [
{
name: "username",
type: "string",
info: "enter username",
value: "test"
}
];
我用一个复杂的函数实现了这个,但我认为它可以用 es6 语法轻松实现。
工作示例:https ://codesandbox.io/s/merged-arrays-18m1t?file=/src/App.js
holdtom
江户川乱折腾
相关分类