Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在支付宝小程序中,可以使用最早期的 小程序异步版本 Canvas 「以下用 CanvasContext 来指代」来满足图形绘制需求(而不需要强依赖新版本的 Canvas 同层实现能力)
实现方案
原始依赖的 CanvasElement 和 getContext('2d') 「以下用 CanvasRenderingContext2D 来指代」 提供了与 W3C 完全一致的 API,但是降级版本的 CanvasContext 内部实现为异步指令批量发送模式,并且需要主动调用
context.draw()
来触发指令提交,因此 API 调用上有如下差异模拟实现
canvasContext.draw()
来同步指令)注意事项
仅假设「Canvas 同层实现能力」不可用,而 「my.createOffscreenCanvas」仍然可用,因此涉及到 OffscreenCanvas 的调用均未处理
API 支持度
未提供以下 API 支持
提供了以下 API 的兼容
属性
方法