Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript HTML5:画布不绘制任何内容_Javascript_Html_Canvas - Fatal编程技术网

Javascript HTML5:画布不绘制任何内容

Javascript HTML5:画布不绘制任何内容,javascript,html,canvas,Javascript,Html,Canvas,我正在学习HTML5。我试着在我的网站上放一块画布,然后在上面画东西。但画布仍然是空白的。我在firefox、chrome和IE中运行了代码,但在所有浏览器中画布都是空白的。我做错什么了吗 HTML文件:- <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>RAMEN</title>

我正在学习HTML5。我试着在我的网站上放一块画布,然后在上面画东西。但画布仍然是空白的。我在firefox、chrome和IE中运行了代码,但在所有浏览器中画布都是空白的。我做错什么了吗

HTML文件:-

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>RAMEN</title>
        <link rel="stylesheet" href="ramenStyle.css">
        <script src="mainScript.js"></script>
    </head>
    <body>
        <div id="main_div">
            <header id="main_header">
                <h1>RAMEN</h1>
            </header>
            <nav id="menu">
                <ul>
                    <li>about</li>
                    <li>history</li>
                    <li>availability</li>
                    <li>flavors</li>
                    <li>worldwide</li>
                </ul>
            </nav>
            <div id="sub_div">
                <section id="main_section">
                    <canvas id="canvas" width="600" height="400">
                    </canvas>
                    <article id="article1">
                        <header>
                            <hgroup>
                                <h4>About Ramen</h4>
                            </hgroup>
                        </header>
                        <p id="about">
                            Ramen is a Japanese noodle soup dish. It consists of Chinese-style wheat noodles served in a meat- or (occasionally) fish-based broth, often flavored with soy sauce or miso, and uses toppings such as sliced pork, dried seaweed, kamaboko, and green onions. Nearly every region in Japan has its own variation of ramen, from the tonkotsu (pork bone broth) ramen of Kyushu to the miso ramen of Hokkaido.
                        </p>
                        <footer>
                            -wikipedia
                        </footer>
                    </article id="article2">
                    <article>
                        <header>
                            <hgroup>
                                <h4>History of Ramen</h4>
                            </hgroup>
                        </header>
                        <p id="history">
                            The origin of ramen is unclear. Some sources say it is of Chinese origin.Other sources say it was invented in Japan in the early 20th century. The name ramen is the Japanese pronunciation of the Chinese lamian. Until the 1950s, ramen was called shina soba, literally "Chinese soba") but today chūka soba, also meaning "Chinese soba") or just Ramen are more common, as the word (shina, meaning "China") has acquired a pejorative connotation.
                        </p>
                        <footer>
                            -wikipedia
                        </footer>
                    </article>
                </section>
                <aside id="side">
                    <h3>News</h3>
                    <p>
                        Pictures of Ramen coming soon!
                    </p>
                </aside>
            </div>
            <footer id="main_footer">
                Copyright Raj 2015 (rkjha3396@gmail.com)
            </footer>
        </div>
    </body>
<html>
它是

不是

函数f(){
console.log('x');
var x=document.getElementById('canvas');
canvas=x.getContext('2d');
canvas.fillRect(10,10100200);
canvas.shadowOffsetX=4;
canvas.shadowOffsetY=4;
canvas.shadowBlur=6;
canvas.shadowColor='rgba(0,0255,5)';
canvas.font=“bold 36px Tahoma”;
canvas.textAlign=“结束”;
fillText(“拉面超级好!”,300100);
}
window.addEventListener(“加载”,f,false)

拉面
  • 关于
  • 历史
  • 可用性
  • 风味
  • 世界各地
关于拉面 拉面是一种日本面条汤。它由中式小麦面和肉汤或(偶尔)鱼汤组成,通常用酱油或味噌调味,并使用猪肉片、海苔干、香菇和青菜等配料 洋葱。日本几乎每个地区都有自己的拉面变体,从九州的通口(猪骨肉汤)拉面到北海道的味噌拉面

-维基百科 拉面历史 拉面的起源尚不清楚。有消息称它起源于中国,也有消息称它是20世纪初在日本发明的。拉面这个名字是中国拉面的日语发音。直到20世纪50年代,拉面才被称为拉面 shina soba,字面意思是“中国soba”),但今天,chūka soba,也意味着“中国soba”)或拉面更为常见,因为这个词(shina,意思是“中国”)已经有了贬义的含义

-维基百科 新闻 拉面马上就要来了

版权所有Raj 2015(rkjha3396@gmail.com)
您是否收到任何错误?检查您的控制台chrome ctrl+shift+I。转到控制台选项卡并搜索错误。这就是我所说的“输入错误”。关于这个问题,有一个很贴切的理由,因为将来不太可能有人会发现它有用。@kaido我应该删除这个问题吗?我不确定。。。在你的情况下,我会这样做。@kaido在发布问题之前,我尽了最大的努力找到问题,但我找不到。我是新来的,所以我不知道它是“上下文”而不是“内容”lol。我想我不会删除这个问题,因为我想给j08691打分以解决我的问题。@Raj。虽然你很想给回答者打分,但你可能想删除你的问题,因为这会误导未来的搜索者,让他们回答一个涉及打字错误而不是有用的问答的问题。
    function f()
{
    var x=document.getElementById('canvas');
    canvas=x.getContent('2d');
    canvas.fillRect(10,10,100,200);
    canvas.shadowOffsetX=4;
    canvas.shadowOffsetY=4;
    canvas.shadowBlur=6;
    canvas.shadowColor='rgba(0,0,255,.5)';
    canvas.font="bold 36px Tahoma";
    canvas.textAlign="end";
    canvas.fillText("Ramen noodles super good!", 300, 100);
}
window.addEventListener("load", f, false);
x.getContext('2d');
x.getContent('2d');