I use VueJS and I want to incorporate the HTML-Canvas
with the Canvas-Context
. I'd like to call the context
from within my components
like:
mounted() {
this.$c.moveTo(100, 100)
this.$c.lineTo(200, 200)
}
I started in my main.js
with:
Vue.prototype.$c = document.querySelector('canvas').getContext('2d')
Furthermore, I also don't know how to work with the keyword this
in a construct like:
const Something = (x, y) => {
this.x = x
this.y = y
this.draw() {
this.$c.moveTo(100, 100)
this.$c.lineTo(200, 200)
}
}
So how can I combine the canvas-context
and VueJS
?