gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 08:41:31 31 4
gpt4 key购买 nike

当我在 Canvas 上添加弯曲文本并使用 JSON.stringify(canvas); 将 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":""}'

但是当我想在 Canvas 上使用canvas.loadFromJSON(front);再次加载上面的json时会发生错误:

Uncaught TypeError: Cannot read property 'async' of undefined fabric.all.min.js:863 (anonymous function) 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 (anonymous function)

最佳答案

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

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

关于javascript - 由fabric.curvedText.js创建的弯曲文本不支持loadFromJSON函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20421454/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com