2

正如文档中所说,我已将所需文件包含在头部

<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js'></script>
<script src='https://cdn1.kongregate.com/javascripts/kongregate_api.js'></script>

然后在我的脚本上方,我包含了应该定义变量的脚本

<script>
    kongregateAPI.loadAPI(function(){
        window.kongregate = kongregateAPI.getAPI();
    });
</script>

但在控制台中我仍然收到此错误 Uncaught ReferenceError: kongregate is not defined

4

1 回答 1

0

You said:

And then right above my scripts i included

Does it mean that your code looks like this?

<script>
    kongregateAPI.loadAPI(function(){
        window.kongregate = kongregateAPI.getAPI();
    });
</script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js'></script>
<script src='https://cdn1.kongregate.com/javascripts/kongregate_api.js'></script>

If so, you should call kongregateAPI functions after you loaded api js file:

<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js'></script>
<script src='https://cdn1.kongregate.com/javascripts/kongregate_api.js'></script>
<script>
    kongregateAPI.loadAPI(function(){
        window.kongregate = kongregateAPI.getAPI();
    });
</script>

I've tried it, everything works fine.

于 2017-02-16T00:25:41.827 回答