javascript - Playground.js 未渲染

标签 javascript

我浏览了 Playground.js 上的前两个教程 website ,但矩形并未渲染矩形。这是目录结构:

index.html
scripts
---main.js
---playground.js

index.html:

<!DOCTYPE html>
<html>
    <head><title>Simple Game</title></head>

    <body>

        <script src="scripts/main.js"></script>
        <script src="scripts/playground.js"></script>
    </body>
</html>

main.js:

var app = playground({
    render: function() {
        this.layer.clear("#000088");
        this.layer.fillStyle("#ffffff");
        this.layer.fillRect(32, 32, 64, 64);
    }
});

playground.js是从网站下载的文件。

出了什么问题,如何解决?

最佳答案

切换您的主脚本标签和 Playground 脚本标签。顺序很重要:

    <script src="scripts/playground.js"></script>
    <script src="scripts/main.js"></script>

关于javascript - Playground.js 未渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38445658/

相关文章:

javascript - 如何让按钮出现在列表项旁边?

javascript - AngularJS $routeProvider 路由按页面不同?

javascript - Angular.js View 不会更新 $http XHR 结果

javascript - 将对象插入数组后,Array.length 读数为 0

javascript - 在特定时间间隔后在 for 循环内执行 setTimeout

php - 如何刷新正在执行php代码的div

javascript - 捆绑 Node.js 后端 - 好的做法还是坏的做法?

javascript - 如何在 RazorViewEngine 中的文本框上添加 onmouseleave 属性

javascript - Facebook 应用程序不提供用户名

javascript - 从文本文件填充 HTML 下拉列表