javascript数组对象排序问题
现在有arr1
和arr2
两个数组,以arr1
字段顺序
和值
为准,对arr2
进行排序
和更新
value值
let arr1 = [
{
title:"姓名",
property:"name",
width:120
},
{
title:"年龄",
property:"age",
width:120
},
{
title:"角色",
property:"role",
width:120
},
{
title:"修改前",
property:"modify",
width:120
children:[
{
title:"体重",
property:"weight",
width:120
},
{
title:"身高",
property:"tall",
width:120
}
]
}
]
let arr2 = [
{
title:"年龄",
property:"age",
width:100,
date:()=>{},
visible:false,
id:2
},
{
title:"修改前",
property:"modify",
width:100,
children:[
{
title:"身高",
property:"tall",
width:100,
visible:true,
id:5
},
{
title:"体重",
property:"weight",
width:100,
visible:true,
id:6
}
]
},
{
title:"姓名",
property:"name",
width:100,
visible:false,
id:3
},
{
title:"角色",
property:"role",
width:100,
visible:true,
id:1
}
]
想要如下效果
let arr3 = [
{
title:"姓名",
property:"name",
width:120,
visible:false,
id:3
},
{
title:"年龄",
property:"age",
width:120,
visible:false,
id:2,
renderWidth: 140,
date:()=>{}
},
{
title:"角色",
property:"role",
width:120,
visible:true,
id:1
},
{
title:"修改前",
property:"modify",
width:120,
children:[
{
title:"体重",
property:"weight",
width:120,
visible:true,
id:6
},
{
title:"身高",
property:"tall",
width:120,
visible:true,
id:5
}
]
}
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我试验后的结果