该方法将TriggerRegion对象转化为JSON格式。
triggerRegion.toJSON()
返回一个JSON格式的对象。
const region = new TriggerRegion();
region.addNode(document.getElementById('foo'));
const json = region.toJSON();
console.log(json);
// 输出: {"type":"dom","nodes":[{"id":"foo","tag":"div","attributes":{}}]}
该方法不接受任何参数。
该方法不抛出任何异常。
本方法用于将TriggerRegion对象转化为JSON格式,并可用于以字符串形式进行传输、存储。转化后的JSON格式如下:
{
"type": "dom", // 类型,目前只有dom
"nodes": [ // 所有包含区域的节点信息列表
{
"id": "foo", // 节点的id
"tag": "div", // 节点的标签名
"attributes": {} // 节点的属性(目前为空)
}
]
}