我曾多次尝试在Google Spreadsheet上的此链接上运行第一个示例代码: https://developers.google.com/apps-script/guides/html/best-practices
Code.gs:
function doGet(request) {
return HtmlService.createTemplateFromFile('Page')
.evaluate();
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
Page.html:
<?!= include('Stylesheet'); ?>
<h1>Welcome</h1>
<p>Please enjoy this helpful script.</p>
<?!= include('JavaScript'); ?>
Stylesheet.html:
<style>
p {
color: green;
}
</style>
JavaScript.html:
<script>
window.addEventListener('load', function() {
alert('Page is loaded');
});
</script>
当我运行代码时,它会显示“正在运行脚本”,然后是“完成脚本”,但我看不到结果。可能是什么原因?