CanvasRenderingContext2D is not defined?
发布于 6 年前 作者 xiuyingyuan 1619 次浏览 来自 问答
CanvasRenderingContext2D.prototype.clear = function() {
....
}

 时遇到该问题,但我看通过以下代码:
  			const query = wx.createSelectorQuery()
  			query.select('#myCanvas')
  				.fields({
  					node: true,
  					size: true
  				})
  				.exec((res) => {
  					const canvas = res[0].node
  					this.canvas = canvas;
  					const ctx = canvas.getContext('2d')
                            ...
                            }
 获取到的ctx 对象就是CanvasRenderingContext2D类型的?
3 回复

基础库多少。

基础库:2.15.0

请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部