fillStyle不是一个函数 [英] fillStyle not a function

查看:156
本文介绍了fillStyle不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个不寻常的错误:


ctx_wrap.fillStyle不是函数
blockquote>

这一行:

  ctx_wrap.fillStyle('#b8b8b8') ; 

在这里:

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

奇怪的是,如果我注释掉那一行,在作品下面。这两行几乎完全相同,但第一行产生错误,第二行有效:

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

为什么第一行会产生错误?

解决方案

尝试使用 ctx_wrap.fillStyle =#COLOR
<第二个不起作用,控制台停在第一个控制台上,并吐出错误,因为它从代码行中吓坏了。


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 comment 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?

解决方案

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.

这篇关于fillStyle不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆