我使用Google HtmlService在網絡上部署應用程序。 我很簡單:Google HtmlService和knockout.js
function doGet() {
return HtmlService.createHtmlOutputFromFile('index').setSandboxMode(HtmlService.SandboxMode.NATIVE);
}
而且我使用jQuery和index.html中knockout.js :
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://knockoutjs.com/downloads/knockout-3.0.0.js" type="text/javascript"> </script>
<body>
Insert text here:
<input type="text">
<br>
asdf
<br>
<script>
var viewModel = {
user_name: "YYK"
}
$(function() {
ko.applyBindings(viewModel);;
});
</script>
</body>
但是當我在瀏覽器中打開我的網站,它的錯誤擊碎
TypeError: undefined is not a function
和噸傾倒。 當我在本地主機上做同樣簡單的事情時,它工作正常! 在Caja sanatization或其他任何方面是否存在問題,以及爲了使knockout.js能夠使用此Google服務而需要做些什麼? 謝謝!
代碼片段中的一些拼寫錯誤(例如缺少關閉腳本標記)。首先解決它們以消除它們作爲問題。 –
插入腳本標籤(jquery,ko)在頭部分或正文部分的末尾,因爲我可以看到當前腳本標籤既不在頭部分也不在主體部分,這可能是一個問題,因爲如果jquery未加載'$'未定義 – gaurav
感謝您指出錯誤,但僅限於此代碼引用。固定。 –