从Fabric.js中的JSON加载加载默认属性

Joh*_*ohn 2 fabricjs

我有画布,其中包含对象centeredRotation:true和其他对象selectable:false 当我将此画布转换为JSON并重新加载它.对象具有默认属性.即没有居中的旋转和物体是可选择的.我可以知道为什么会这样吗?显然,像centralRotation,selectable这样的属性不包含在JSON中.

{ "类型": "矩形", "originX": "左", "originY": "顶", "左":92, "顶部":53, "宽度":150, "高度":150,"填写 ":" #778899" , "中风":空, "strokeWidth":1, "strokeDashArray":空, "strokeLineCap": "对接", "strokeLineJoin": "人字", "strokeMiterLimit":10",将scaleX ":1," 的scaleY ":1," 角度 ":0",flipX ":假" flipY ":假," 不透明性 ":0.4," 影子 ":空," 可见 ":真" clipTo":空 "的backgroundColor": "", "RX":0, "RY":0, "×":0, "Y":0}], "背景": ""}

如何在加载对象时设置这些?

kan*_*gax 8

您需要在以下期间包括它们toJSON:

canvas.toJSON([ 'centeredRotation', 'selectable' ]);
Run Code Online (Sandbox Code Playgroud)

请参阅描述此"propertiesToInclude"参数的文档,toJSON并提供一些示例.