Skip to content

canvas添加渐变色报错 #371

Closed
Closed
@zhe-he

Description

问题描述
在ctx.setStrokeStyle(gradient1); 此处报错,Uncaught (in promise) TypeError: t.toLowerCase is not a function。
改为 ctx.setStrokeStyle('rgba(255,255,255,0.3)')不报错
复现步骤

 var gradient1 = ctx.createCircularGradient(50, 50, 100);
 gradient1.addColorStop(0, 'red');
 gradient1.addColorStop(1, 'yellow');
 ctx.setStrokeStyle(gradient1);
 ctx.setLineWidth(2);
 ctx.stroke();
 ctx.closePath();```


**预期结果**
设置一个渐变的线条
**实际结果**
setStrokeStyle报错->Uncaught (in promise) TypeError: t.toLowerCase is not a function。

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions