js对象遍历循环
有时候需要对对象的每一个key和value进行循环
const Allinfo = {
shape.background: null,
shape.border.width: 2,
Name: "线路1",
CDXS: 1,
XL_MAX_GL: 10000,
YX_BYQ_JD: 0,
ZT: 1,
GZL: 1,
XF_Time: 1,
label.color: "rgb(255,255,255)",
YJLX: "变压器"
}
let info = Object.entries(AllInfo)
//不包括名称的复制
info.forEach((element,index) => {
if (element[0] != "Name") {
console.log(element +'======>'+index)
}
});
/**
* shape.background,======>0
* shape.border.width,2======>1
* CDXS,1======>3
* XL_MAX_GL,10000======>4
* YX_BYQ_JD,0======>5
* ZT,1======>6
* GZL,1======>7
* XF_Time,1======>8
* label.color,rgb(255,255,255)======>9\
* YJLX,变压器======>10
*/