canvas接口strokeStyle is not a function?

发布于 7 年前作者 dguo5279 次浏览最后编辑 7 年前来自 issues

使用CanvasContext.strokeStyle替代废弃接口CanvasContext.setStrokeStyle时报以下错误,官方说两个接口的用法一样而且使用的代码就是官方的例子

用的CanvasContext.lineWidth CanvasContext.lineCap 一样报错

WXOPEN Club 内容图片

以下是代码片段

<canvas canvas-id="myCanvas"></canvas>
const ctx = wx.createCanvasContext('myCanvas')
ctx.strokeStyle('red')
ctx.strokeRect(10, 10, 150, 75)
ctx.draw()

求解答!!!!!

2 回复
jun16
jun161 楼6 年前

ctx.strokeStyle = “red”

umeng
umeng2 楼5 年前

!!