代码之家  ›  专栏  ›  技术社区  ›  Mladen Skrbic

如何编辑svg并将其作为数据发送

  •  1
  • Mladen Skrbic  · 技术社区  · 6 年前

    2 回复  |  直到 6 年前
        1
  •  2
  •   Dmitriy Snitko    6 年前

    <svg xmlns="http://www.w3.org/2000/svg" #container>
        <!-- your svg here -->
    </svg>
    

    组件.ts

    @ViewChild('container')
    container: ElementRef;
    
    saveSvg() {
      const svg = this.container.nativeElement.outerHTML;
      // your code to save svg
    }
    
        2
  •  1
  •   FallenWarrior    6 年前

    如果你有推荐人,说 el <svg /> 元素(例如 document.getElementById() el.outerHTML .

    这个值是一个字符串,您可以通过任何方式发送到后端。