当我在画布上添加弯曲文本并使用JSON.stringify(canvas);
函数将画布转换为JSON时,我得到的JSON如下:
var front='{"objects":[{"type":"curvedText","originX":"center","originY":"center","left":180,"top":110,"width":149,"height":100.26,"fill":"rgb(0,0,0)","overlayFill":null,"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,"scaleX":1,"scaleY":1,"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,"text":"trstererer","fontSize":30,"fontWeight":"bold","fontFamily":"conv_bpreplayextended","fontStyle":"","lineHeight":1.3,"textDecoration":"","textShadow":"","textAlign":"center","path":null,"backgroundColor":"","textBackgroundColor":"","useNative":true,"radius":50,"spacing":15,"reverse":false,"bulge":true,"curve":false,"pintch":false,"arch":false,"wedge":false,"roof":false,"bridge":false,"vally":false}],"background":""}'
但是当我想再次在json上加载时,会出现错误在画布上使用canvas.loadFromJSON(front);
:
未捕获的TypeError:无法读取未定义的属性“async” fabric.all.min.js:863(匿名函数)fabric.all.min.js:863 v fabric.all.min.js:860 fabric.util.object.extend._enlivenObjects fabric.all.min.js:3719 fabric.util.object.extend.loadFromJSON fabric.all.min.js:3700(匿名函数)
答案 0 :(得分:0)
最后我解决了这个问题。
我已将fabric.curvedText.js中的代码添加到fabric.all.min
然后解决e.type undefined问题。
然后我在getKlass上搜索了很多,最后得到了解决方案:
https://groups.google.com/forum/#!topic/fabricjs/oLDIW_MoRRY 此处
我已将type=curvedText
和类名称设为fabric.CurvedText
,但不匹配
现在我已将其更改为fabric.Curvedtext
,这真是令人惊讶......
谢谢Kangax n Yesh。