我有以下對象傳遞給我一個數組裏面的函數:是否有可能從javascript中獲取特定屬性的對象數組?
[ { id: 'WA1WA1WAbWA2WAaWAbWA9WA6-WAdWA2WAaWAd-4WAbWAcWA3-WAbWA3WA7WAa-WAcWAbWA8WA9WAcWA9WA9WA9WA3WA3WA3WA9',
obj: '<svg data="BusinessProductFigure" x="484.171875" y="123" id="WA1WA1WAbWA2WAaWAbWA9WA6-WAdWA2WAaWAd-4WAbWAcWA3-WAbWA3WA7WAa- WAcWAbWA8WA9WAcWA9WA9WA9WA3WA3WA3WA9"
xmlns="http://www.w3.org/2000/svg" version="1.1"><rect x="4" y="4"
width="60" height="14" fill="rgb(299,299,162)" stroke-linejoin="round"
stroke="rgb(299,299,162)" stroke-width="1"/></svg>' } ]
是有可能得到單獨的變量,是SVG標記中的X和Y值?是否有任何條件或分隔符可以用於某種方式?
使用[的DOMParser](https://developer.mozilla.org/en/docs/Web/API/DOMParser)來解析它,然後從DOM中讀取值。 –
@RobertLongson我得到了文檔,但我現在如何訪問各個變量? – Arihant
我想通了。剛剛使用過doc.getElementsByTagName [「svg」]。getAttribute(「x」);非常感謝! – Arihant