gpt4 book ai didi

google-apps-script - 使用 Include 时 Apps 脚本边栏引用错误

转载 作者:行者123 更新时间:2023-12-04 13:22:11 27 4
gpt4 key购买 nike

我创建了一个 Google Apps Script单击时显示侧边栏的附加组件:

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 中的内容无关紧要它总是失败。

我以前做过这个,而且有效。据我所知,我像其他项目一样设置了这个,但它在这个项目中不起作用。我假设我忘记启用某些东西,但不知道如何判断缺少什么,因为成绩单含糊不清。

我错过了什么?或者,做错了?

最佳答案

我也疯了...
在 Google Script Reference 中提供的示例中找到它,我不知道 include() 是用户定义的函数。粘贴此代码,它将起作用:

function include(File) {
return HtmlService.createHtmlOutputFromFile(File).getContent();
};

让我知道我是否理解正确。

关于google-apps-script - 使用 Include 时 Apps 脚本边栏引用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42141355/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com