在我的 html 编辑器上,此代码可以工作,但是当我使用用于 google 脚本的 Code.gs 上传它时。
function doGet() {
return HtmlService.createHtmlOutputFromFile('hh');
}
它应该显示与我的 html 编辑器中相同的布局,但看起来不同。您可以在这里看到它:
https://script.google.com/macros/s/AKfycbwM0y5y3kkgWAoPb99hXwdJKTpvt3hvXwWLHvzehbcw/dev
<title>jQuery Mobile</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</script>
<body>
<!-- label text -->
<div data-role="page">
<div data-role="header" data-theme="a">
<h1>Example</h1>
<form id="form" name="form">
</div>
<div style="width:auto; margin:20px;padding-top:30px;">
<label for="howMuch_1">How much?</label>
<input id ="howMuch_1" type="range" min="1" max="100" value="1">
<label for="howMany_1">How many tickets?</label>
<input id ="howMany_1" type="range" min="1" max="50" value="1">
<label for="lastNumber_1">Last number?</label>
<input id ="lastNumber_1" type="range" max="700" min="1" value="1">
<button id="add" ></button>
</div>
</form>
</div>
</body>
最佳答案
我猜测 CAJA 已经清理并删除了 jQuery Mobile 的一些功能。但这只是一个猜测。尝试使用:
return HtmlService.createTemplateFromFile('hh')
.evaluate() // evaluate MUST come before setting the NATIVE mode
.setTitle('Title of your app')
.setSandboxMode(HtmlService.SandboxMode.NATIVE);
将沙盒模式设置为 NATIVE 可能会有所帮助,但我不能保证。
引用文献:
引用:
To protect users from being served malicious HTML or JavaScript, Apps Script relies on the Caja Compiler to sanitize and sandbox HTML-service web apps or custom user interfaces for Google Docs, Sheets, and Forms.
关于javascript - 上传到 Google 脚本 HTML 时,Google 脚本不显示 jQuery 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24624016/