假设我有arrow.svg
文件。在我使用香草JS的index.js
中,我想将appendChild
设置为正文。我该怎么办?
const theSVGFile = //... read from './arrow.svg'
document.getElementById('some-id').appendChild(theSVGFile);
答案 0 :(得分:0)
Zoilo建议的一个例子通常是最简单的方法,但现实是他值得称赞,因为他击败了我。
const daSVGHost = document.createElement("img");
daSVGHost.src = "https://i.stack.imgur.com/BVW9D.jpg"; // SVG HERE
document.getElementById('testerooni').appendChild(daSVGHost);
<div id="testerooni"></div>