javascript - fillStyle not a function - Stack Overflow

I'm getting an unusual error:ctx_wrap.fillStyle is not a functionon this line:ctx_wrap.fillStyle(&

I'm getting an unusual error:

ctx_wrap.fillStyle is not a function

on this line:

ctx_wrap.fillStyle('#b8b8b8');

in here:

...
this.paint = function() {
    self.path(ctx_wrap);
    if (!isOver) {
        ctx_wrap.fillStyle('#b8b8b8');
    } else {
        ctx_wrap.fillStyle('#d6d6d6'); 
    }
    ctx_wrap.fill()
    ctx_wrap.stroke();
};
...

What is strange is that, if I ment out that line, the line beneath works. These two lines are nearly identical, but the first one produces the error and the second one works:

ctx_wrap.fillStyle('#b8b8b8');
ctx_wrap.fillStyle('#d6d6d6');

Why would the first line produce the error?

I'm getting an unusual error:

ctx_wrap.fillStyle is not a function

on this line:

ctx_wrap.fillStyle('#b8b8b8');

in here:

...
this.paint = function() {
    self.path(ctx_wrap);
    if (!isOver) {
        ctx_wrap.fillStyle('#b8b8b8');
    } else {
        ctx_wrap.fillStyle('#d6d6d6'); 
    }
    ctx_wrap.fill()
    ctx_wrap.stroke();
};
...

What is strange is that, if I ment out that line, the line beneath works. These two lines are nearly identical, but the first one produces the error and the second one works:

ctx_wrap.fillStyle('#b8b8b8');
ctx_wrap.fillStyle('#d6d6d6');

Why would the first line produce the error?

Share Improve this question edited Jun 9, 2017 at 4:14 Pang 10.1k146 gold badges86 silver badges124 bronze badges asked Feb 22, 2017 at 3:28 Michael GaioMichael Gaio 1651 gold badge4 silver badges13 bronze badges 1
  • How do you get the ctx_wrap object ? By using HTMLCanvasElement.getContext("2d") or special method to draw ? – defghi1977 Commented Feb 22, 2017 at 4:12
Add a ment  | 

1 Answer 1

Reset to default 9

Try using ctx_wrap.fillStyle = "#COLOR".

The second one does not work, the console just stops at the first one and spits out the error, because it freaked out from the line of code.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744318752a4568308.html

相关推荐

  • javascript - fillStyle not a function - Stack Overflow

    I'm getting an unusual error:ctx_wrap.fillStyle is not a functionon this line:ctx_wrap.fillStyle(&

    8天前
    80

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信