Google Apps脚本边栏参考错误使用包括当
问题描述:
我创建了一个Google Apps Script
附加上单击显示侧边栏:Google Apps脚本边栏参考错误使用包括当
function displayPage_() {
getScriptProperties_()
var htmlTemplate = HtmlService.createTemplateFromFile('PAGE');
var html = htmlTemplate.evaluate()
.setTitle('Connector');
SpreadsheetApp.getUi().showSidebar(html);
}
这成功地加载文件PAGE.html
,只要它是简单的HTML。然而,当我尝试添加include
这样的:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<?!= include("STYLESHEET"); ?>
</head>
<body>
</body>
</html>
它抛出这个错误:
[17-02-09 08:55:50:239 MST] Execution failed: ReferenceError: "include" is not defined.
不要紧,它是什么总是失败的include
。
我已经完成了这之前,它的工作。据我所知,我的设置与其他项目一样,但在此项目中不起作用。我假设我忘记启用某些内容,但不知道如何判断缺失的内容,因为记录内容很模糊。
我缺少什么?或者,做错了?
答
我疯了太... 在谷歌脚本参考了一个示例发现了它,什么我不知道的是,包括()是一个用户定义的函数。粘贴此代码,它将工作:
function include(File) {
return HtmlService.createHtmlOutputFromFile(File).getContent();
};
让我知道,如果我理解正确。
我觉得很傻:) – davids
我放心了!谢谢! – brianestey