我正在尝试将GameSparks SDK添加到我的Vue项目中,但是出现了一些问题。
将GameSparks添加到普通网页时,您可以这样做:
<script type="text/javascript" src="gamesparks.js"></script>
<script type="text/javascript" src="gamesparks-functions.js"></script>
<script type="text/javascript" src="hmac-sha256.js"></script>
然后您可以在javascript中运行它:
var gamesparks = new GameSparks();
function init() {
gamesparks.initLive({
key: gsKey,
secret: gsSecret,
//credential: gsCredentials,
onNonce: onNonce,
onInit: onInit,
onMessage: onMessage,
logger: console.log,
});
}
function onNonce(nonce) {
return CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(nonce, gsSecret));
}
//Callback to handle when the SDK is initialized and ready to go
function onInit() {
console.log("Initialised");
}
init();
现在!我在我的main.js文件中添加了3个javascript,如下所示:
import GS from './assets/gamesparks/gamesparks'
import GSfunc from './assets/gamesparks/gamesparks-functions'
import Sha256 from './assets/gamesparks/hmac-sha256'
但这给我一个错误:
未捕获的ReferenceError:未定义GameSparks 在评估时(gamesparks-functions.js?7884:1)
我的问题是...如何在vue中正确实现脚本?
真的希望她能有所帮助...我疯了:-/