物件屬性值賦給變數

出太陽下雨�發表於2020-12-09

物件屬性值賦給變數

  如果一個物件中有多個值,想把物件的屬性值提取為變數。

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

相關文章