本文介绍了初始化后,Fabric.js将我的画布大小更改为300x150的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HTML:
<div class="canvas-wrapper">
<canvas id="myCanvas"></canvas>
</div>
CSS
.canvas-wrapper {
width: 900px;
min-height: 600px;
}
#myCanvas{
border:1px solid red;
position: absolute;
top:22px;
left:0px;
height: 100%;
width: 99%;
}
JS
var myCanvas = new fabric.Canvas('myCanvas');
我的画布在初始化后调整为300x150,为什么?
My canvas get resized to 300x150 after it's been initialized, why?
推荐答案
在最新版本中,您必须执行以下操作:
in the latest version, you will have to do something like:
var canvas = new fabric.Canvas('myCanvas');
canvas.setHeight(500);
canvas.setWidth(800);
....你的代码....
.... Your code ....
canvas.renderAll();
对我来说工作正常..
Works fine for me..
这篇关于初始化后,Fabric.js将我的画布大小更改为300x150的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!