HTML에 포함 된 SVG를 복제하고 내부에 ID를 다시 정의하고 싶습니다.클로저 라이브러리를 사용하여 HTML에 포함 된 SVG DOM을 복제하는 방법은 무엇입니까?
예를 들어,
<html>
<body>
<div id="svgs">
</div>
<!-- Template -->
<div style="display:none;">
<svg xmlns="http://www.w3.org/2000/svg" width="181" height="59" id="type0svg">
<g style="display:inline" transform="translate(0,0)">
<text id="ph1" x="23.6" y="51.7">ph1</text>
<text id="ph2" x="105.1" y="51">ph2</text>
</g>
</svg>
</div>
</body>
</html>
및 데이터 [{ph1:'placeholder1',ph2:'placeholder2'},{ph1:'apple',ph2:'orange'}]
같은 HTML 파일이 있습니다. 나는 ... 같은 DOM을 생성 복사 DOM 아래의 모든 ID가 'blahblah_1'와 'blahblah_2'에서 'blahblah'에서 다시 정의되어 있는지
<html>
<body>
<div id="svgs">
<!-- {ph1:'placeholder1',ph2:'placeholder2'} -->
<svg xmlns="http://www.w3.org/2000/svg" width="181" height="59" id="type0svg1">
<g style="display:inline" transform="translate(0,0)">
<text id="ph1_1" x="23.6" y="51.7">placeholder1</text>
<text id="ph2_1" x="105.1" y="51">placeholder2</text>
</g>
</svg>
<!-- {ph1:'apple',ph2:'orange'} -->
<svg xmlns="http://www.w3.org/2000/svg" width="181" height="59" id="type0svg2">
<g style="display:inline" transform="translate(0,0)">
<text id="ph1_2" x="23.6" y="51.7">apple</text>
<text id="ph2_2" x="105.1" y="51">orange</text>
</g>
</svg>
</div>
<!-- Template -->
<div style="display:none;">
<svg xmlns="http://www.w3.org/2000/svg" width="181" height="59" id="type0svg">
<g style="display:inline" transform="translate(0,0)">
<text id="ph1" x="23.6" y="51.7">ph1</text>
<text id="ph2" x="105.1" y="51">ph2</text>
</g>
</svg>
</div>
</body>
</html>
공지하고자합니다.
어떻게하면 Google 폐쇄 라이브러리를 사용하여 현명하게 수행 할 수 있습니까? 노드의
복제 :