创建svg节点时,要使用createElementNS函数并传入节点名称的命名空间。
如:
<svg id="st_mind_map" width="100%" height="100%"></svg>
this.svg = document.getElementById('st_mind_map');
var path = document.createElementNS("http://www.w3.org/2000/svg","path");
path.setAttribute('fill','none');
path.setAttribute('stroke-linecap','square');
path.setAttribute('d','M 80 161 L 87 161 C 102 161 87 29 150 29');
path.setAttribute('stroke','#4D94FF');
this.svg.append(path)
最后效果: