there are two arrays, array An on the left is written dead, I put the data of array An on the left into array B on the right after logical processing, the data structure of array An and B are the same, the name of the array is different, when I operate array B, such as B.splice (index, 1), the element of the current index position of array An is also deleted, how to avoid this problem?
The code is as follows:
json format
leftMenu:
[{
lv: 1,
collspan: true ,
menuId: "1-1",
menuText: "-",
// iconClass:"../static/nav/toTop.png"
subMenu: [
{
menuText: "",
menuId: "1-1-1",
lv: 2,
url:"",
// iconClass:"../static/nav/toTop.png"
},
{
menuText: "",
menuId: "1-1-2",
lv: 2,
url:""
},
{
menuText: "",
menuId: "1-1-3",
lv: 2,
url:""
},
{
menuText: "",
menuId: "1-1-4",
lv: 2,
url:""
}
]
}]
this.editMenuData.push (leftMenu)
editMenuData array is empty, logical processing, need to add leftMenu objects to editMenuData array, editMenuData data structure is consistent with leftMenu data structure,