I did make it a plugin.
import fabric from 'fabric'
export default ({ Vue }) => {
Vue.prototype.$fabric = fabric
}
then add a test.vue in components.
mounted () {
var canvas = new this.$fabric.fabric.Canvas('canvas')
var rect = new this.$fabric.fabric.Rect({
left: 100,
top: 150,
fill: 'red',
width: 200,
height: 200
})
canvas.add(rect)
}
but nothing happened.