OffscreenCanvas()

Baseline 2023

Newly available

Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

**OffscreenCanvas()**构造函数,返回一个新的 OffscreenCanvas 对象

语法

new OffscreenCanvas(width, height);

参数

width

离屏 canvas 的高度

height

离屏 canvas 的宽度

示例

创建一个离屏 Canvas 并且初始一个 WebGL 上下文:

js
var offscreen = new OffscreenCanvas(256, 256);
var gl = offscreen.getContext("webgl");

规范

Specification
HTML Standard
# dom-offscreencanvas-dev

浏览器兼容性

BCD tables only load in the browser

查看更多