js数组里面对象排序问题
现在有obj1
和obj2
两个对象,以obj1
字段顺序
和值
为准,对obj2
对象进行排序和更新value值
let obj1 = [
{
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 obj2 = [
{
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 obj3 = [
{
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)
我下面这个用的是方案1,比较位置。