canvas-confetti icon indicating copy to clipboard operation
canvas-confetti copied to clipboard

canvas.getContext is not a function

Open ricky11 opened this issue 3 years ago • 2 comments

When creating a canvas as :

var canvas = this.$refs.notifyContainer canvas.confetti = confetti.create(canvas, { resize: true })

canvas.confetti({ spread: 70, origin: { y: 1.2 } });

console shows error : "TypeError: canvas.getContext is not a function"

I am using vue, and $refs is a way to reach in to dom, effetely its the same as getElementbyId

without canvas , the confetti appears to display as normal in the middle of the screen.

What i need is for the confetti to be displayed within the dev, just like your canvas demo.

ricky11 avatar Nov 24 '21 07:11 ricky11

Try canvas = confetti.create(canvas, { resize: true }) instead

kirkegaard avatar Nov 25 '21 17:11 kirkegaard

I am not familiar with vue. Do you have a reduced reproduction case for this issue? getContext is a standard method on the canvas, so I would expect that the value you are passing in as canvas is in fact not an actual canvas.

catdad avatar Dec 24 '21 05:12 catdad

Closing this bug due to inactivity. If this is still an issue, please let me know and we can reopen this bug or create a new one.

catdad avatar Aug 08 '22 21:08 catdad