Empty scrawl.library.canvas (canvas could not be found?) in Vue2 #23
-
I am new to scrawl-canvas (like 10-minutes in kind of new), so my first goal is to get the hello world to work within my Vue2 project (soon to be Vue3), with the end goal of generating a downloadable 256x256 avatar based on a transparent png + circular mask + another image (seems within the realm of Scrawl-canvas possibilities, right?). I'm trying the hello world example from the front page. But this being Vue, this happens within a component:
However, the canvas object remains empty. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, Sjoerd82 I'm not sure I can be of much help to you here as I have no experience of using the Vue framework. I have managed to add SC to a very basic React website, and also to Svelte (as seen in the library's website, which is built using Svelte). There's a couple of "How Do I" articles on how to include SC in these frameworks, which might offer some insights? React: https://scrawl-v8.rikweb.org.uk/how-do-i/add-to-a-react-project/ If you do manage to solve the issue, then I'll be more than happy to add a similar Vue article to the website. Edit: Try replacing SC runs once on initial load which, given that it's probably in a bundle of code, will be on initial load of the site. The component code adds a canvas element to the DOM, but SC won't automatically pick it up. Instead you have to run the |
Beta Was this translation helpful? Give feedback.
-
Thanks, that was helpful. It's actually:
So, the instructions for Vue2 (and probably Vue3) are simply to call
|
Beta Was this translation helpful? Give feedback.
Hi, Sjoerd82
I'm not sure I can be of much help to you here as I have no experience of using the Vue framework. I have managed to add SC to a very basic React website, and also to Svelte (as seen in the library's website, which is built using Svelte). There's a couple of "How Do I" articles on how to include SC in these frameworks, which might offer some insights?
React: https://scrawl-v8.rikweb.org.uk/how-do-i/add-to-a-react-project/
Svelte: https://scrawl-v8.rikweb.org.uk/how-do-i/add-to-a-svelte-project/
If you do manage to solve the issue, then I'll be more than happy to add a similar Vue article to the website.
Edit:
Try replacing
let canvas = scrawl.library.canvas.mycanvas
withlet …