我尝试在includeDefaultValues:false
每次创建对象时设置,但是,图像的保存字符串仍然是:
[{"type":"image","originX":"center","originY":"center","left":396.16,"top":108.16,"width":2475,"height":675,"fill":"rgb(0,0,0)","overlayFill":null,"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,"scaleX":0.32,"scaleY":0.32,"angle":0,"flipX":false,"flipY":false,"opacity":1,"selectable":true,"hasControls":true,"hasBorders":true,"hasRotatingPoint":true,"transparentCorners":true,"perPixelTargetFind":false,"shadow":null,"visible":true,"clipTo":null,"src":"http://localhost/fabricjstest/designs/images/ds130814014834.png?t=1376502517","filters":[]}],"background":"#FFF"}
我很确定其中大部分都是默认值,那么我怎样才能让它工作呢?也许我保存错误,所以这是我的保存代码:
var obj = canvas.toObject();
var jsn = JSON.stringify(obj);
alert(jsn);
这是直接来自 js 文件的版本:var fabric=fabric||{version:"1.2.9"};
所以问题是:如何禁用默认值。