语法
js
toJSON()
参数
无。
返回值
一个新的对象,其属性值设置为调用该方法的 DOMQuad
中的值。
示例
此示例创建一个 DOMQuad
,其中包含四个表示当前窗口角的 DOMPoint
对象(使用屏幕坐标),然后将其转换为 JSON。
js
const topLeft = new DOMPoint(window.screenX, window.screenY);
const topRight = new DOMPoint(
window.screenX + window.innerWidth,
window.screenY,
);
const bottomLeft = new DOMPoint(
window.screenX,
window.screenY + window.innerHeight,
);
const bottomRight = new DOMPoint(
window.screenX + window.innerWidth,
window.screenY + window.innerHeight,
);
const quad = new DOMQuad(topLeft, topRight, bottomRight, bottomLeft);
const quadJSON = quad.toJSON();
规范
规范 |
---|
Geometry Interfaces Module Level 1 # dom-domquad-tojson |
浏览器兼容性
加载中…