简体   繁体   English

如何将easyljs链接到我的html文件并且createjs未定义?

[英]How can I link easeljs to my html file & createjs is not defined?

this is the first time i am using easljs.i've downloaded all the zip file of easljs and extracted it.i wrote some code which will draw a circle on the canvas.but nothing is happening.what i have tried with src gave me an error "creratejs is not defined".i can't figur out hot to add the easljs script to my html code .what should i put in the script src inside the head?please help me out 这是我第一次使用easljs。我已经下载了easljs的所有zip文件并解压缩了。我写了一些代码会在画布上画一个圆圈。但没有任何反应。我用src尝试过的东西给了我错误“ creratejs未定义”。我无法搞清楚将easljs脚本添加到我的html代码中。我应该在头部的src脚本中放什么内容?请帮帮我

    <style>
        #mycanvas{
            width:500;
            height:500;
            border:1px solid black;
        }
    </style>

    <script src=""></script>
</head>
<body onload="init();">
<script>
     function init(){
         var stage=new createjs.stage("mycanvas");
         var circle=new createjs.shape();
         circle.graphics.beginFill('red').drawCircle(0,0,50);
         circle.x=100;
         circle.y=100;
         stage.addChild(circle);
         stage.update();
    }
</script>
<canvas id="mycanvas" ></canvas>
</body>
</html>

I notice you have this script tag in the head of your html file <script src=""></script> . 我注意到您在html文件<script src=""></script>具有此脚本标记。

The src attribute is blank and needs to point at your createjs file. src属性为空白,需要指向您的createjs文件。 If you are running on localhost I would suggest moving createjs into this and then linking to this file. 如果您在localhost上运行,建议将createjs移至其中,然后链接至该文件。

Make sure that you are waiting for that file to load by having the script tag above the script file where you are using createjs. 通过在使用createjs的脚本文件上方放置script标记,确保等待加载该文件。

Alternatively use the createjs CDN like this: 或者像这样使用createjs CDN:

<script src="http://code.createjs.com/createjs-2013.12.12.min.js"></script>
<script>
    function init() {
        console.log(createjs);
    }

</script>

Read more about the cdn here . 在此处阅读有关CDN的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM