0
Я пытаюсь использовать fabric.js, и прямо сейчас я пытаюсь представить изображение для экспериментов.Uncaught TypeError: Невозможно прочитать свойство 'width' of null
Я следовал the tutorial, но даже в этом случае я получаю следующее сообщение об ошибке:
Uncaught TypeError: Cannot read property 'width' of null
... которая относится к линии 14805 в all.js:
_setWidthHeight: function(options) {
this.width = 'width' in options
? options.width
: (this.getElement().width || 0); // <------ this line
this.height = 'height' in options
? options.height
: (this.getElement().height || 0);
},
Мой код (HTML):
...
<div id="avatarBox">
<canvas id="canvas" width="500" height="500"/>
<img src="img/test.png" id="my-image">
</div>
...
Мой код (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);
Что может быть не так?
Отлично, не видел этого! Ошибка в их документах тогда ... Спасибо! – holyredbeard
Спасибо, я исправил документы – kangax