admin管理员组文章数量:1406726
My wordpress plugin works with fabric.js 1.2.0, When I change it to work with fabric.js 1.7.9 then it throws the error on all the pages other than plugin page:
Cannot create property 'style' on string 'wtd_background_image'
on the following line:
canvasObj= new fabric.Canvas('wtd_background_image');
My wordpress plugin works with fabric.js 1.2.0, When I change it to work with fabric.js 1.7.9 then it throws the error on all the pages other than plugin page:
Cannot create property 'style' on string 'wtd_background_image'
on the following line:
canvasObj= new fabric.Canvas('wtd_background_image');
Share
Improve this question
edited Mar 29, 2017 at 15:17
HOY
asked Mar 29, 2017 at 15:07
HOYHOY
1,00712 gold badges42 silver badges86 bronze badges
1 Answer
Reset to default 6You'll need to create an HTML Canvas Element with an id wtd_background_image
, on all your pages.
let canvas = new Canvas('wtd_background_image');
let canvasObj = new fabric.Canvas('wtd_background_image');
function Canvas(id) {
this.canvas = document.createElement('canvas');
this.canvas.id = id;
document.body.appendChild(this.canvas);
return this.canvas;
}
// for demonstration
let circle = new fabric.Circle({radius: 20, fill: '#07C', left: 30, top: 30});
canvasObj.add(circle);
<script src="http://cdnjs.cloudflare./ajax/libs/fabric.js/1.7.9/fabric.min.js"></script>
本文标签:
版权声明:本文标题:javascript - Uncaught TypeError: Cannot create property 'style' on string 'wtd_background_image' 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745035038a2638732.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论