繁体   English   中英

由fabric.curvedText.js创建的弯曲文本不支持loadFromJSON函数

[英]Curved text created by fabric.curvedText.js not supporting loadFromJSON function

当我在画布上添加弯曲文本并使用JSON.stringify(canvas);将画布转换为JSON时JSON.stringify(canvas); 函数,我得到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":""}'

但是当我想再次使用canvas.loadFromJSON(front);在画布上再次加载json时发生错误canvas.loadFromJSON(front);

未捕获到的TypeError:无法读取未定义的fabric.all.min.js:863(匿名函数)fabric.all.min.js:863 v fabric.all.min.js:860 fabric.util.object.extend的属性'async' ._enlivenObjects fabric.all.min.js:3719 fabric.util.object.extend.loadFromJSON fabric.all.min.js:3700(匿名函数)

终于我找到了解决这个问题的方法。

我已经将来自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。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM