0
我正在尝试使用fabric.js,现在我正试图放入一个图像进行实验。未捕获TypeError:无法读取null属性的'宽度'
我已经按照the tutorial但即便如此,我得到以下错误:
Uncaught TypeError: Cannot read property 'width' of null
...这是指在all.js排队14805:
_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 2013-05-02 11:49:47
谢谢,我修复了文档 – kangax 2013-05-03 00:32:10