Snap.svg icon indicating copy to clipboard operation
Snap.svg copied to clipboard

Solution for using snap-svg in Vue

Open ap1969 opened this issue 4 years ago • 2 comments

Hi all,

I've been reading about all the webpack-related issues, eve being undefined, and so on, and decided to put together a solution for using Snap.svg in Vue 3.

The solution is pretty straightforward, so should be relatively easy to map across to React, and it may even work in Vue 2 as-is.

Hope it helps.

Here's the gist.

Regards, Andy

ap1969 avatar Jul 22 '21 09:07 ap1969

https://www.npmjs.com/package/snapsvg-cjs-ts

Alex-Golovin avatar Dec 17 '22 08:12 Alex-Golovin

Used like this

<template>
  <svg id="svg"></svg>
</template>

<script>
import * as Snap from 'snapsvg-cjs'

export default {
  mounted() {
    this.drawChart();
  },
  methods: {
    drawChart() {
      
       var s = Snap('#tree');
       s.rect(0,0, 100, 100);
     
    },
  },
};
</script>

<style>
#svg {
  width: 100%;
  height: 100%;
}
</style>

ralexrdz avatar Sep 22 '23 05:09 ralexrdz