canvas type "2d" 不支持嘛?
-
taro canvas 组件不支持 type 属性值嘛?
-
楼主解决了吗? 我也遇到同样问题了
-
支持吧 我的项目刚用了2d的 canvas
<Canvas type='2d' id='myCanvas' className='my-canvas'></Canvas>
下面是获取上下文的方法
// 获取canvas 上下文
getCanvas = height => {
// 创建查询 选择节点 获取节点实例
Taro.createSelectorQuery()
.select(#myCanvas
)
.fields({ node: true, size: true })
.exec(async res => {
console.log(res
, res[0])
this.canvas = res[0].node
await this.setState({height})
// 设置画布的宽高
this.canvas.width = 600
this.canvas.height = height
let ctx = await this.canvas.getContext('2d')
// 根据图片数量生成不同的海报
console.log(去生成海报
)
await this.saveCanvasToImage(ctx, height)
// 轮询能保存海报的时候 保存海报
this.loopDramPoster(height)
})
}