GPUCanvasContext: canvas 属性

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

安全上下文: 此功能仅在安全上下文(HTTPS)中可用,且支持此功能的浏览器数量有限。

注意:此功能在 Web Workers 中可用。

GPUCanvasContext 接口的 canvas 只读属性返回创建该上下文所用的 canvas 的引用。

一个 HTMLCanvasElementOffscreenCanvas 对象实例。

示例

js
const canvas = document.querySelector("#gpuCanvas");
const context = canvas.getContext("webgpu");

// returns an HTMLCanvasElement reference
context.canvas;

规范

规范
WebGPU
# dom-gpucanvascontext-canvas

浏览器兼容性

另见