SOURCE

console 命令行工具 X clear

                    
>
console
 // 命名空间

  var SVG_NS = "http://www.w3.org/2000/svg"
  var svgArea = document.getElementById('svgArea')

  // 1、创建svg容器
  var svg = document.createElementNS(SVG_NS, 'svg')

  // 2、创建svg中的 tag, 如rect
//   var tag = document.createElementNS(SVG_NS, 'rect')

 // 2、创建svg中的 tag, 如rect
  var g = document.createElementNS(SVG_NS, 'g')
    var path = document.createElementNS(SVG_NS, 'path')
    //  width="16" height="8" viewBox="0 0 16 8" fill="none" xmlns="http://www.w3.org/2000/svg"
    svg.setAttribute('width','16')
    svg.setAttribute('height','8')
    svg.setAttribute('viewBox','0 0 16 8')
    svg.setAttribute('fill','none')
    svg.setAttribute('xmlns','http://www.w3.org/2000/svg')
    g.setAttribute('id','chevron-up-active')
    path.setAttribute('id','Union')
    path.setAttribute('d','M12.4583 5.53774L11.5391 6.45698L7.99868 2.9166L4.4583 6.45698L3.53906 5.53774L7.99868 1.07812L12.4583 5.53774Z')
    path.setAttribute('fill','#864BFF')

    //   svg.appendChild(tag)
    svg.appendChild(g)
    g.appendChild(path)
    // 5、将svg塞进指定容器
    svgArea.appendChild(svg)

<div id="svgArea"></div>