dav*_*ids 6 sidebar google-apps-script
我创建了一个Google Apps Script加载项,可以在点击时显示侧边栏:
function displayPage_() {
getScriptProperties_()
var htmlTemplate = HtmlService.createTemplateFromFile('PAGE');
var html = htmlTemplate.evaluate()
.setTitle('Connector');
SpreadsheetApp.getUi().showSidebar(html);
}
Run Code Online (Sandbox Code Playgroud)
PAGE.html只要它是简单的html,这就成功加载了文件.但是,当我尝试添加include如下:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<?!= include("STYLESHEET"); ?>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
它抛出此错误:
[17-02-09 08:55:50:239 MST] Execution failed: ReferenceError: "include" is not defined.
Run Code Online (Sandbox Code Playgroud)
什么在include它总是失败并不重要.
我以前做过这件事并且有效.据我所知,我的设置就像其他项目一样,但它在这个项目中不起作用.我假设我忘了启用某些东西,但不知道如何分辨遗漏的内容,因为成绩单含糊不清.
我错过了什么?或者,做错了?
k4k*_*sh1 15
我也疯狂了......在Google脚本参考中提供的示例中找到它,我不知道的是include()是用户定义的函数.粘贴此代码,它将工作:
function include(File) {
return HtmlService.createHtmlOutputFromFile(File).getContent();
};
Run Code Online (Sandbox Code Playgroud)
如果我理解得当,请告诉我.
| 归档时间: |
|
| 查看次数: |
1300 次 |
| 最近记录: |