对象属性值赋给变量
如果一个对象中有多个值,想把对象的属性值提取为变量。
let itemobj = {
"datasize": "1,1",
"datapos": "1,3",
"uid": "13519494246273345",
"pageid": "EnergyPortal",
"componentid": "ZJ011",
"url": "keyAreaAnalysis.html",
"name": "重点区域用能",
"configurl": "/admin/ImportantAreaConfig.html",
"ctype": 0,
"psysno": ""
}
const {
url,
name,
componentid,
pageid,
configurl,
usetitle,
uid,
} = itemobj;
console.log(url) // 此时url的值为keyAreaAnalysis.html