How to configure Fabric.js in vue?

I just stumbled upon the same combination: Fabric.js and Vue.js, and I was wondering, but I have been working with VueJs for several days and I don’t know how to configure fabric in vue. Can you share some experience for me?

+5
source share
2 answers

Assuming you are using ES6 and a kit like Webpack, you can start using Fabric.js as follows:

  • At the command line:

    npm add fabric (or yarn add fabric )

  • Then import it into a .js file.

    import { fabric } from 'fabric'

  • Then configure the Canvas method in Vue mounted:

Note. For me, by default, the fabric npm module led to a rather large package. I ended up using the fabric-browseronly . Fabric.js has many features that you might not need, in which case you can create your own version here or through the command line.

+1
source

The fabric follows a fairly traditional distribution.

You want to use the files from the dist directory. fabric.js for development and fabric.min.js for a live site.

0
source

Source: https://habr.com/ru/post/1264448/


All Articles