我创建了一个Google Apps Script加载项以在单击时显示侧边栏:
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); }只要是简单的html,它就会成功加载文件PAGE.html.但是,当我尝试这样添加include时:
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>它抛出此错误:
[17-02-09 08:55:50:239 MST] Execution failed: ReferenceError: "include" is not defined.include中的什么都不重要,它总是会失败.
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()是用户定义的函数.粘贴此代码即可使用:
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.
更多推荐
使用包括时的Apps脚本边栏参考错误
发布评论