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类型的?
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
在draw()函数的中间,增加:
Date.prototype.clear = function() {};
CanvasRenderingContext2D.prototype.clear = function() {}
对Date的操作不会出错,但对CanvasRenderingContext2D的操作就会报错!在watch看,Date是函数类型,CanvasRenderingContext2D为<note available>,如图:
以及文档:https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D
基础库:2.15.0
基础库多少。