我创建了一个Google Apps Script插件,在点击时显示一个侧边栏:
function displayPage_() { getScriptProperties_() var htmlTemplate = HtmlService.createTemplateFromFile('PAGE'); var html = htmlTemplate.evaluate() .setTitle('Connector'); SpreadsheetApp.getUi().showSidebar(html); }只要它是简单的html,就可以成功加载文件PAGE.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什么,它总是失败。
我之前完成了这个工作,它工作。 据我所知,我的设置与其他项目一样,但在此项目中不起作用。 我假设我忘记启用某些内容,但不知道如何判断缺失的内容,因为记录内容很模糊。
我错过了什么? 或者,做错了?
I created a Google Apps Script add-on to display a sidebar on click:
function displayPage_() { getScriptProperties_() var htmlTemplate = HtmlService.createTemplateFromFile('PAGE'); var html = htmlTemplate.evaluate() .setTitle('Connector'); SpreadsheetApp.getUi().showSidebar(html); }This successfully loads the file PAGE.html as long as it is simple html. However, when I try to add include like this:
<!DOCTYPE html> <html> <head> <base target="_top"> <?!= include("STYLESHEET"); ?> </head> <body> </body> </html>It throws this error:
[17-02-09 08:55:50:239 MST] Execution failed: ReferenceError: "include" is not defined.It doesn't matter what is in the include it always fails.
I have done this before and it worked. As far as I can tell, I have this set up just like the other project, but it doesn't work in this project. I assume that I forgot to enable something, but don't know how to tell what is missing because the transcript is vague.
What am I missing? Or, doing wrong?
最满意答案
我也疯了......在Google脚本参考中提供的示例中找到它,我不知道的是include()是用户定义的函数。 粘贴这个代码,它会工作:
function include(File) { return HtmlService.createHtmlOutputFromFile(File).getContent(); };如果我理解正确,请告诉我。
I got crazy too... Found it in an example provided in Google Script Reference, what I didn't know was that include() is a user-defined function. Paste this code and it will work:
function include(File) { return HtmlService.createHtmlOutputFromFile(File).getContent(); };Let me know if I understood properly.
更多推荐
发布评论