javascript - Uncaught TypeError: Cannot read property 'width' of null -
i'm trying out fabric.js, , right i'm trying put in image experiment with.
i've followed the tutorial following error:
uncaught typeerror: cannot read property 'width' of null
... refers line 14805 in all.js:
_setwidthheight: function(options) { this.width = 'width' in options ? options.width : (this.getelement().width || 0); // <------ line this.height = 'height' in options ? options.height : (this.getelement().height || 0); },
my code (html):
... <div id="avatarbox"> <canvas id="canvas" width="500" height="500"/> <img src="img/test.png" id="my-image"> </div> ...
my code (js):
var canvas = new fabric.canvas('canvas'); var imgelement = document.getelementbyid('my-img'); var imginstance = new fabric.image(imgelement, { left: 100, top: 100, angle: 30, opacity: 0.85 }); canvas.add(imginstance);
what can wrong?
you don't have "my-img" in html. have "my-image", maybe problem comes there?
Comments
Post a Comment