CanvasRenderingContext2D.canvas

CanvasRenderingContext2D.canvas 属性是只读的,是 HTMLCanvasElement的反向引用。如果没有 <canvas> 元素与之对应,对象值为null

语法

ctx.canvas;

示例

给出 <canvas> 元素:

<canvas id="canvas"></canvas>

你可以通过CanvasRenderingContext2D调用内部的canvas属性,获取canvas的一个反向引用:

var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.canvas // HTMLCanvasElement

规范描述

Specification Status Comment
WHATWG HTML Living Standard
CanvasRenderingContext2D.canvas
Living Standard  

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

参见

文档标签和贡献者

 此页面的贡献者: ice-i-snow
 最后编辑者: ice-i-snow,