gpt4 book ai didi

javascript - kongregate未定义错误javascript

转载 作者:行者123 更新时间:2023-12-01 05:30:20 24 4
gpt4 key购买 nike

我已按照文档中的说明将所需的文件包含在头部中

<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 未定义

最佳答案

你说:

And then right above my scripts i included

这是否意味着您的代码看起来像这样?

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

如果是这样,您应该在加载 api js 文件后调用 kongregateAPI 函数:

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

我已经尝试过,一切正常。

关于javascript - kongregate未定义错误javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38018179/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com