已知有画布组件:[canvas canvas-id='myCanvas'][/]以下哪句代码可以用于创建该画布的上下文?
A: const ctx=wx.createCanvasContext()
B: const ctx=wx.createCanvasContext('canvas')
C: const ctx=wx.createCanvasContext('canvasId')
D: const ctx=wx.createCanvasContext('canvasId')
A: const ctx=wx.createCanvasContext()
B: const ctx=wx.createCanvasContext('canvas')
C: const ctx=wx.createCanvasContext('canvasId')
D: const ctx=wx.createCanvasContext('canvasId')
举一反三
- API函数wx.createCanvasContext(string canvasId, Object this)用于创建 画布的绘图上下文对象(
- 中国大学MOOC: 以下代码片段的运行结果是否正确?const ctx = wx.createCanvasContext(myCanvas) ctx.setFillStyle(red)ctx.fillRect(10, 10, 150, 100)ctx.draw()ctx.fillRect(50, 50, 150, 100)ctx.draw()运行结果:
- 以下代码片段的运行结果是否正确?( )const ctx = wx.createCanvasContext('myCanvas')ctx.setFillStyle('red')ctx.setShadow(10, 50, 50, 'blue')ctx.fillRect(10, 10, 150, 75)ctx.draw()运行结果:[img=303x153]18033276d2a20f1.png[/img]
- 以下代码片段的运行结果是否正确?( )const ctx = wx.createCanvasContext('myCanvas')ctx.setFillStyle('red')ctx.fillRect(10, 10, 150, 100)ctx.draw()ctx.fillRect(50, 50, 150, 100)ctx.draw()运行结果:[img=304x154]1803743b5b53483.png[/img]
- 以下代码片段的运行结果是否正确?const ctx = wx.createCanvasContext('myCanvas')ctx.save()ctx.setFillStyle('red')ctx.fillRect(10, 10, 150, 100)ctx.restore()ctx.fillRect(50, 50, 150, 100)ctx.draw()运行结果:[img=316x169]18033276670a461.png[/img]