簡體   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