Created
December 21, 2019 02:47
-
-
Save vitorvargasdev/e9d0df56d101d4c207f53f6e57d4742a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<canvas id="canvas"></canvas> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
img_src: "/images/img_teste1.jpeg", | |
img_loaded: '' | |
}; | |
}, | |
methods: { | |
imgGenerate() { | |
const img = new Image(); | |
img.src = this.img_src; | |
img.onload = () => { | |
this.draw(img); | |
this.img_loaded = img; | |
}; | |
}, | |
draw(img) { | |
const canvas = document.getElementById("canvas"); | |
const ctx = canvas.getContext("2d"); | |
ctx.drawImage(img, 0, 0); | |
} | |
}, | |
mounted() { | |
this.imgGenerate(); | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment