【发布时间】:2021-06-12 13:27:48
【问题描述】:
我正在向我的织物对象添加自定义属性,如下所示,它可以正常工作,但是当使用 JSON.stringify 将对象转换为字符串时,它不会转换我添加的属性
var customcanva = new fabric.Canvas('c');
// my text object with custom attribute
text = new fabric.IText('Tap and Type', {
attr0: 'value 0',
});
// with another custom attribute
text.attr1 = "value 1";
// object showing fine as json object
console.log(text);
// stringified object doesn't have all attributes including my added ones
console.log(JSON.stringify(text));
我这样做是为了可以通过 ajax 请求发送我选择的对象。如何使我的属性保持不变?
【问题讨论】:
标签: javascript json fabricjs stringify