3
我跟着Smoochinstructions沒有成功。用RequireJS設置smooch-js
這裏是最少的代碼爲我失敗:
<!doctype html><html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.min.js"></script>
<script>
require.config({
"paths": {
"smooch": "https://cdn.smooch.io/smooch.min"
}
});
// Tried this
require(["require", "smooch"], function(require){
var Smooch = require("smooch");
console.log(Smooch); // → undefined
});
// Tried that
require(["smooch"], function(Smooch){
console.log(Smooch); // → undefined
});
</script>
</head>
<body></body>
</html>
require
返回我爲我的undefined
所以沒有Smooch.init(...)
。在Firefox和Chrome上進行測試。
我做錯了什麼?
非常感謝,確實解決了這個問題。我想我已經嘗試過'Smooch'而不是'smooch',但是我必須在這一點上有其他的東西被破壞,然後回覆到自述所說的內容。 –
沒問題!我們將更新文檔以更好地解釋這一點。 –