3
有沒有一種方法可以將自定義屬性添加到對象並在導出的SVG上獲取它們?如何使用fabric.js中的自定義屬性導出SVG?
我使用這種方式進行JSON導出。但它不適用於SVG導出。
canvas.item(0).foo = 'bar'; // custom property
var json = JSON.stringify(canvas.toJSON(['foo'])); // include that property in json
canvas.clear();
canvas.loadFromJSON(json);
canvas.item(0).foo; // "bar" <-- the property is preserved
當我使用canvas.toSVG()導出畫布時,不會導出自定義屬性。